MCPcopy
hub / github.com/grafana/tempo / fakeServerWithObjectAttributes

Function fakeServerWithObjectAttributes

tempodb/backend/gcs/gcs_test.go:281–313  ·  view source on GitHub ↗
(t *testing.T, o *raw.Object)

Source from the content-addressed store, hash-verified

279}
280
281func 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
315func TestObjectWithPrefix(t *testing.T) {
316 tests := []struct {

Callers 1

Calls 4

GetMethod · 0.65
CloseMethod · 0.65
DecodeMethod · 0.65
WriteMethod · 0.65

Tested by

no test coverage detected