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

Function TestAPIClient_403_Forbidden

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

Source from the content-addressed store, hash-verified

307}
308
309func TestAPIClient_403_Forbidden(t *testing.T) {
310 mock := testutil.NewMockAPI()
311 defer mock.Close()
312
313 errBody := testutil.LoadFixture("error_responses/403.json")
314 mock.On("GET", "/monitors", 403, errBody)
315
316 client := newTestClient(mock.Server.URL)
317 resp, err := client.GET("/monitors", nil)
318 if err != nil {
319 t.Fatalf("unexpected error: %v", err)
320 }
321
322 if resp.StatusCode != 403 {
323 t.Errorf("expected 403, got %d", resp.StatusCode)
324 }
325
326 parsed := resp.ParseError()
327 if !strings.Contains(parsed, "Invalid API key") {
328 t.Errorf("expected 'Invalid API key', got %q", parsed)
329 }
330}
331
332func TestAPIClient_404_NotFound(t *testing.T) {
333 mock := testutil.NewMockAPI()

Callers

nothing calls this directly

Calls 7

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

Tested by

no test coverage detected