(t *testing.T)
| 918 | } |
| 919 | |
| 920 | func TestAPIClient_StatuspageEndpoints(t *testing.T) { |
| 921 | mock := testutil.NewMockAPI() |
| 922 | defer mock.Close() |
| 923 | client := newTestClient(mock.Server.URL) |
| 924 | |
| 925 | tests := []struct { |
| 926 | name string |
| 927 | do func() (*lib.APIResponse, error) |
| 928 | method string |
| 929 | path string |
| 930 | }{ |
| 931 | {"list statuspages", func() (*lib.APIResponse, error) { return client.GET("/statuspages", nil) }, "GET", "/statuspages"}, |
| 932 | {"get statuspage", func() (*lib.APIResponse, error) { return client.GET("/statuspages/main", nil) }, "GET", "/statuspages/main"}, |
| 933 | {"create statuspage", func() (*lib.APIResponse, error) { |
| 934 | return client.POST("/statuspages", []byte(`{"name":"Main"}`), nil) |
| 935 | }, "POST", "/statuspages"}, |
| 936 | {"update statuspage", func() (*lib.APIResponse, error) { |
| 937 | return client.PUT("/statuspages/main", []byte(`{"name":"Updated"}`), nil) |
| 938 | }, "PUT", "/statuspages/main"}, |
| 939 | {"delete statuspage", func() (*lib.APIResponse, error) { return client.DELETE("/statuspages/main", nil, nil) }, "DELETE", "/statuspages/main"}, |
| 940 | {"list components", func() (*lib.APIResponse, error) { return client.GET("/statuspage_components", nil) }, "GET", "/statuspage_components"}, |
| 941 | {"create component", func() (*lib.APIResponse, error) { |
| 942 | return client.POST("/statuspage_components", []byte(`{"statuspage":"main"}`), nil) |
| 943 | }, "POST", "/statuspage_components"}, |
| 944 | {"delete component", func() (*lib.APIResponse, error) { |
| 945 | return client.DELETE("/statuspage_components/comp-001", nil, nil) |
| 946 | }, "DELETE", "/statuspage_components/comp-001"}, |
| 947 | } |
| 948 | |
| 949 | for _, tt := range tests { |
| 950 | t.Run(tt.name, func(t *testing.T) { |
| 951 | mock.Reset() |
| 952 | _, err := tt.do() |
| 953 | if err != nil { |
| 954 | t.Fatalf("unexpected error: %v", err) |
| 955 | } |
| 956 | req := mock.LastRequest() |
| 957 | if req.Method != tt.method { |
| 958 | t.Errorf("expected %s, got %s", tt.method, req.Method) |
| 959 | } |
| 960 | if req.Path != tt.path { |
| 961 | t.Errorf("expected %s, got %s", tt.path, req.Path) |
| 962 | } |
| 963 | }) |
| 964 | } |
| 965 | } |
| 966 | |
| 967 | func TestAPIClient_MetricEndpoints(t *testing.T) { |
| 968 | mock := testutil.NewMockAPI() |
nothing calls this directly
no test coverage detected