(t *testing.T)
| 244 | } |
| 245 | |
| 246 | func TestHTTPClient_PathHandling(t *testing.T) { |
| 247 | tests := []struct { |
| 248 | name string |
| 249 | inputPath string |
| 250 | expectedPath string |
| 251 | }{ |
| 252 | {"path with leading slash", "/api/test", "/api/test"}, |
| 253 | {"path without leading slash", "api/test", "/api/test"}, |
| 254 | {"root path", "/", "/"}, |
| 255 | {"empty path", "", "/"}, |
| 256 | } |
| 257 | |
| 258 | for _, tt := range tests { |
| 259 | t.Run(tt.name, func(t *testing.T) { |
| 260 | server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { |
| 261 | assert.Equal(t, tt.expectedPath, r.URL.Path) |
| 262 | w.WriteHeader(http.StatusOK) |
| 263 | _ = json.NewEncoder(w).Encode(map[string]interface{}{"success": true}) |
| 264 | })) |
| 265 | defer server.Close() |
| 266 | |
| 267 | client := NewHTTPClient(server.Client(), server.URL, testutils.NewTestLogger()) |
| 268 | |
| 269 | var result map[string]interface{} |
| 270 | err := client.Get(context.Background(), tt.inputPath, &result) |
| 271 | require.NoError(t, err) |
| 272 | }) |
| 273 | } |
| 274 | } |
| 275 | |
| 276 | func TestHTTPClient_HTTPErrors(t *testing.T) { |
| 277 | tests := []struct { |
nothing calls this directly
no test coverage detected