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

Function TestAPIClient_GET

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

Source from the content-addressed store, hash-verified

25}
26
27func TestAPIClient_GET(t *testing.T) {
28 mock := testutil.NewMockAPI()
29 defer mock.Close()
30
31 fixture := testutil.LoadFixture("monitors_list.json")
32 mock.On("GET", "/monitors", 200, fixture)
33
34 client := newTestClient(mock.Server.URL)
35 resp, err := client.GET("/monitors", nil)
36 if err != nil {
37 t.Fatalf("unexpected error: %v", err)
38 }
39
40 if resp.StatusCode != 200 {
41 t.Errorf("expected status 200, got %d", resp.StatusCode)
42 }
43
44 req := mock.LastRequest()
45 if req.Method != "GET" {
46 t.Errorf("expected GET, got %s", req.Method)
47 }
48 if req.Path != "/monitors" {
49 t.Errorf("expected /monitors, got %s", req.Path)
50 }
51}
52
53func TestAPIClient_GET_WithQueryParams(t *testing.T) {
54 mock := testutil.NewMockAPI()

Callers

nothing calls this directly

Calls 7

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

Tested by

no test coverage detected