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

Function TestAPIClient_MaintenanceEndpoints

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

Source from the content-addressed store, hash-verified

876}
877
878func TestAPIClient_MaintenanceEndpoints(t *testing.T) {
879 mock := testutil.NewMockAPI()
880 defer mock.Close()
881 client := newTestClient(mock.Server.URL)
882
883 tests := []struct {
884 name string
885 do func() (*lib.APIResponse, error)
886 method string
887 path string
888 }{
889 {"list", func() (*lib.APIResponse, error) { return client.GET("/maintenance_windows", nil) }, "GET", "/maintenance_windows"},
890 {"get", func() (*lib.APIResponse, error) { return client.GET("/maintenance_windows/maint-001", nil) }, "GET", "/maintenance_windows/maint-001"},
891 {"create", func() (*lib.APIResponse, error) {
892 return client.POST("/maintenance_windows", []byte(`{"name":"Deploy"}`), nil)
893 }, "POST", "/maintenance_windows"},
894 {"update", func() (*lib.APIResponse, error) {
895 return client.PUT("/maintenance_windows/maint-001", []byte(`{"name":"Updated"}`), nil)
896 }, "PUT", "/maintenance_windows/maint-001"},
897 {"delete", func() (*lib.APIResponse, error) {
898 return client.DELETE("/maintenance_windows/maint-001", nil, nil)
899 }, "DELETE", "/maintenance_windows/maint-001"},
900 }
901
902 for _, tt := range tests {
903 t.Run(tt.name, func(t *testing.T) {
904 mock.Reset()
905 _, err := tt.do()
906 if err != nil {
907 t.Fatalf("unexpected error: %v", err)
908 }
909 req := mock.LastRequest()
910 if req.Method != tt.method {
911 t.Errorf("expected %s, got %s", tt.method, req.Method)
912 }
913 if req.Path != tt.path {
914 t.Errorf("expected %s, got %s", tt.path, req.Path)
915 }
916 })
917 }
918}
919
920func TestAPIClient_StatuspageEndpoints(t *testing.T) {
921 mock := testutil.NewMockAPI()

Callers

nothing calls this directly

Calls 9

CloseMethod · 0.95
ResetMethod · 0.95
LastRequestMethod · 0.95
NewMockAPIFunction · 0.92
newTestClientFunction · 0.85
GETMethod · 0.80
POSTMethod · 0.80
PUTMethod · 0.80
DELETEMethod · 0.80

Tested by

no test coverage detected