MCPcopy Create free account
hub / github.com/cronitorio/cronitor-cli / TestAPIClient_GET_WithQueryParams

Function TestAPIClient_GET_WithQueryParams

lib/api_client_test.go:53–78  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

51}
52
53func 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
80func TestAPIClient_GET_EmptyQueryParamsOmitted(t *testing.T) {
81 mock := testutil.NewMockAPI()

Callers

nothing calls this directly

Calls 7

CloseMethod · 0.95
OnMethod · 0.95
LastRequestMethod · 0.95
NewMockAPIFunction · 0.92
newTestClientFunction · 0.85
GETMethod · 0.80
GetMethod · 0.80

Tested by

no test coverage detected