(t *testing.T, o *raw.Object)
| 279 | } |
| 280 | |
| 281 | func fakeServerWithObjectAttributes(t *testing.T, o *raw.Object) *httptest.Server { |
| 282 | server := httptest.NewUnstartedServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { |
| 283 | // Check that we are making the call to update the attributes before attempting to decode the request body. |
| 284 | if strings.HasPrefix(r.RequestURI, "/upload/storage/v1/b/blerg2") { |
| 285 | |
| 286 | _, params, err := mime.ParseMediaType(r.Header.Get("Content-Type")) |
| 287 | require.NoError(t, err) |
| 288 | |
| 289 | reader := multipart.NewReader(r.Body, params["boundary"]) |
| 290 | defer r.Body.Close() |
| 291 | |
| 292 | for { |
| 293 | part, err := reader.NextPart() |
| 294 | if errors.Is(err, io.EOF) { |
| 295 | break |
| 296 | } |
| 297 | require.NoError(t, err) |
| 298 | defer part.Close() |
| 299 | |
| 300 | if part.Header.Get("Content-Type") == "application/json" { |
| 301 | err = json.NewDecoder(part).Decode(&o) |
| 302 | require.NoError(t, err) |
| 303 | } |
| 304 | } |
| 305 | } |
| 306 | |
| 307 | _, _ = w.Write([]byte(`{}`)) |
| 308 | })) |
| 309 | server.StartTLS() |
| 310 | t.Cleanup(server.Close) |
| 311 | |
| 312 | return server |
| 313 | } |
| 314 | |
| 315 | func TestObjectWithPrefix(t *testing.T) { |
| 316 | tests := []struct { |
no test coverage detected