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

Function TestDelete

tempodb/backend/s3/s3_test.go:544–613  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

542}
543
544func TestDelete(t *testing.T) {
545 tests := []struct {
546 name string
547 prefix string
548 objectName string
549 keyPath backend.KeyPath
550 httpHandler func(t *testing.T) http.HandlerFunc
551 }{
552 {
553 name: "without prefix",
554 prefix: "",
555 objectName: "object",
556 keyPath: backend.KeyPath{"test"},
557 httpHandler: func(t *testing.T) http.HandlerFunc {
558 return func(w http.ResponseWriter, r *http.Request) {
559 if r.Method == getMethod {
560 assert.Equal(t, r.URL.Query().Get("prefix"), "")
561
562 _, _ = w.Write([]byte(`<?xml version="1.0" encoding="UTF-8"?>
563 <ListBucketResult>
564 </ListBucketResult>`))
565 return
566 }
567 assert.Equal(t, "/blerg/test/object", r.URL.String())
568 w.WriteHeader(http.StatusNoContent)
569 }
570 },
571 },
572 {
573 name: "with prefix",
574 prefix: "test_storage",
575 objectName: "object",
576 keyPath: backend.KeyPath{"test"},
577 httpHandler: func(t *testing.T) http.HandlerFunc {
578 return func(w http.ResponseWriter, r *http.Request) {
579 if r.Method == getMethod {
580 assert.Equal(t, r.URL.Query().Get("prefix"), "test_storage")
581
582 _, _ = w.Write([]byte(`<?xml version="1.0" encoding="UTF-8"?>
583 <ListBucketResult>
584 </ListBucketResult>`))
585 return
586 }
587 assert.Equal(t, "/blerg/test_storage/test/object", r.URL.String())
588 w.WriteHeader(http.StatusNoContent)
589 }
590 },
591 },
592 }
593
594 for _, tc := range tests {
595 t.Run(tc.name, func(t *testing.T) {
596 server := testServer(t, tc.httpHandler(t))
597 _, w, _, err := New(&Config{
598 Region: "blerg",
599 AccessKey: "test",
600 SecretKey: flagext.SecretWithValue("test"),
601 Bucket: "blerg",

Callers

nothing calls this directly

Calls 10

QueryMethod · 0.80
testServerFunction · 0.70
NewFunction · 0.70
GetMethod · 0.65
WriteMethod · 0.65
DeleteMethod · 0.65
EqualMethod · 0.45
StringMethod · 0.45
WriteHeaderMethod · 0.45
RunMethod · 0.45

Tested by

no test coverage detected