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

Function TestObjectWithPrefix

tempodb/backend/azure/azure_test.go:182–245  ·  tempodb/backend/azure/azure_test.go::TestObjectWithPrefix
(t *testing.T)

Source from the content-addressed store, hash-verified

180}
181
182func TestObjectWithPrefix(t *testing.T) {
183 tests := []struct {
184 name string
185 prefix string
186 objectName string
187 keyPath backend.KeyPath
188 httpHandler func(t *testing.T) http.HandlerFunc
189 }{
190 {
191 name: "with prefix",
192 prefix: "test_prefix",
193 objectName: "object",
194 keyPath: backend.KeyPath{"test_path"},
195 httpHandler: func(t *testing.T) http.HandlerFunc {
196 return func(w http.ResponseWriter, r *http.Request) {
197 if r.Method == "GET" {
198 _, _ = w.Write([]byte(``))
199 return
200 }
201
202 assert.Equal(t, "/testing_account/blerg/test_prefix/test_path/object", r.URL.Path)
203 w.WriteHeader(http.StatusCreated)
204 }
205 },
206 },
207 {
208 name: "without prefix",
209 prefix: "",
210 objectName: "object",
211 keyPath: backend.KeyPath{"test_path"},
212 httpHandler: func(t *testing.T) http.HandlerFunc {
213 return func(w http.ResponseWriter, r *http.Request) {
214 if r.Method == "GET" {
215 _, _ = w.Write([]byte(``))
216 return
217 }
218
219 assert.Equal(t, "/testing_account/blerg/test_path/object", r.URL.Path)
220 w.WriteHeader(http.StatusCreated)
221 }
222 },
223 },
224 }
225
226 for _, tc := range tests {
227 t.Run(tc.name, func(t *testing.T) {
228 server := testServer(t, tc.httpHandler(t))
229 _, w, _, err := New(&Config{
230 StorageAccountName: "testing_account",
231 StorageAccountKey: flagext.SecretWithValue("YQo="),
232 MaxBuffers: 3,
233 BufferSize: 1000,
234 ContainerName: "blerg",
235 Prefix: tc.prefix,
236 Endpoint: server.URL[7:], // [7:] -> strip http://,
237 })
238 require.NoError(t, err)
239

Callers

nothing calls this directly

Calls 6

testServerFunction · 0.70
NewFunction · 0.70
WriteMethod · 0.65
EqualMethod · 0.45
WriteHeaderMethod · 0.45
RunMethod · 0.45

Tested by

no test coverage detected