(t *testing.T)
| 180 | } |
| 181 | |
| 182 | func 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 |
nothing calls this directly
no test coverage detected