(t *testing.T)
| 51 | } |
| 52 | |
| 53 | func TestAPIClient_GET_WithQueryParams(t *testing.T) { |
| 54 | mock := testutil.NewMockAPI() |
| 55 | defer mock.Close() |
| 56 | |
| 57 | mock.On("GET", "/monitors", 200, `{"monitors":[]}`) |
| 58 | |
| 59 | client := newTestClient(mock.Server.URL) |
| 60 | params := map[string]string{ |
| 61 | "page": "2", |
| 62 | "type": "job", |
| 63 | "env": "production", |
| 64 | "search": "backup", |
| 65 | } |
| 66 | _, err := client.GET("/monitors", params) |
| 67 | if err != nil { |
| 68 | t.Fatalf("unexpected error: %v", err) |
| 69 | } |
| 70 | |
| 71 | req := mock.LastRequest() |
| 72 | for key, expected := range params { |
| 73 | got := req.QueryParams.Get(key) |
| 74 | if got != expected { |
| 75 | t.Errorf("query param %s: expected %q, got %q", key, expected, got) |
| 76 | } |
| 77 | } |
| 78 | } |
| 79 | |
| 80 | func TestAPIClient_GET_EmptyQueryParamsOmitted(t *testing.T) { |
| 81 | mock := testutil.NewMockAPI() |
nothing calls this directly
no test coverage detected