(t *testing.T)
| 749 | } |
| 750 | |
| 751 | func TestAPIClient_EnvironmentEndpoints(t *testing.T) { |
| 752 | mock := testutil.NewMockAPI() |
| 753 | defer mock.Close() |
| 754 | client := newTestClient(mock.Server.URL) |
| 755 | |
| 756 | tests := []struct { |
| 757 | name string |
| 758 | do func() (*lib.APIResponse, error) |
| 759 | method string |
| 760 | path string |
| 761 | }{ |
| 762 | {"list", func() (*lib.APIResponse, error) { return client.GET("/environments", nil) }, "GET", "/environments"}, |
| 763 | {"get", func() (*lib.APIResponse, error) { return client.GET("/environments/prod", nil) }, "GET", "/environments/prod"}, |
| 764 | {"create", func() (*lib.APIResponse, error) { |
| 765 | return client.POST("/environments", []byte(`{"key":"staging"}`), nil) |
| 766 | }, "POST", "/environments"}, |
| 767 | {"update", func() (*lib.APIResponse, error) { |
| 768 | return client.PUT("/environments/staging", []byte(`{"name":"QA"}`), nil) |
| 769 | }, "PUT", "/environments/staging"}, |
| 770 | {"delete", func() (*lib.APIResponse, error) { return client.DELETE("/environments/old", nil, nil) }, "DELETE", "/environments/old"}, |
| 771 | } |
| 772 | |
| 773 | for _, tt := range tests { |
| 774 | t.Run(tt.name, func(t *testing.T) { |
| 775 | mock.Reset() |
| 776 | _, err := tt.do() |
| 777 | if err != nil { |
| 778 | t.Fatalf("unexpected error: %v", err) |
| 779 | } |
| 780 | req := mock.LastRequest() |
| 781 | if req.Method != tt.method { |
| 782 | t.Errorf("expected %s, got %s", tt.method, req.Method) |
| 783 | } |
| 784 | if req.Path != tt.path { |
| 785 | t.Errorf("expected %s, got %s", tt.path, req.Path) |
| 786 | } |
| 787 | }) |
| 788 | } |
| 789 | } |
| 790 | |
| 791 | func TestAPIClient_NotificationEndpoints(t *testing.T) { |
| 792 | mock := testutil.NewMockAPI() |
nothing calls this directly
no test coverage detected