(t *testing.T)
| 876 | } |
| 877 | |
| 878 | func 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 | |
| 920 | func TestAPIClient_StatuspageEndpoints(t *testing.T) { |
| 921 | mock := testutil.NewMockAPI() |
nothing calls this directly
no test coverage detected