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

Function TestAPIClient_NotificationEndpoints

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

Source from the content-addressed store, hash-verified

789}
790
791func TestAPIClient_NotificationEndpoints(t *testing.T) {
792 mock := testutil.NewMockAPI()
793 defer mock.Close()
794 client := newTestClient(mock.Server.URL)
795
796 tests := []struct {
797 name string
798 do func() (*lib.APIResponse, error)
799 method string
800 path string
801 }{
802 {"list", func() (*lib.APIResponse, error) { return client.GET("/notifications", nil) }, "GET", "/notifications"},
803 {"get", func() (*lib.APIResponse, error) { return client.GET("/notifications/default", nil) }, "GET", "/notifications/default"},
804 {"create", func() (*lib.APIResponse, error) {
805 return client.POST("/notifications", []byte(`{"name":"DevOps"}`), nil)
806 }, "POST", "/notifications"},
807 {"update", func() (*lib.APIResponse, error) {
808 return client.PUT("/notifications/devops", []byte(`{"name":"Updated"}`), nil)
809 }, "PUT", "/notifications/devops"},
810 {"delete", func() (*lib.APIResponse, error) { return client.DELETE("/notifications/old", nil, nil) }, "DELETE", "/notifications/old"},
811 }
812
813 for _, tt := range tests {
814 t.Run(tt.name, func(t *testing.T) {
815 mock.Reset()
816 _, err := tt.do()
817 if err != nil {
818 t.Fatalf("unexpected error: %v", err)
819 }
820 req := mock.LastRequest()
821 if req.Method != tt.method {
822 t.Errorf("expected %s, got %s", tt.method, req.Method)
823 }
824 if req.Path != tt.path {
825 t.Errorf("expected %s, got %s", tt.path, req.Path)
826 }
827 })
828 }
829}
830
831func TestAPIClient_IssueEndpoints(t *testing.T) {
832 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