(t *testing.T)
| 707 | } |
| 708 | |
| 709 | func TestAPIClient_GroupEndpoints(t *testing.T) { |
| 710 | mock := testutil.NewMockAPI() |
| 711 | defer mock.Close() |
| 712 | client := newTestClient(mock.Server.URL) |
| 713 | |
| 714 | tests := []struct { |
| 715 | name string |
| 716 | do func() (*lib.APIResponse, error) |
| 717 | method string |
| 718 | path string |
| 719 | }{ |
| 720 | {"list groups", func() (*lib.APIResponse, error) { return client.GET("/groups", nil) }, "GET", "/groups"}, |
| 721 | {"get group", func() (*lib.APIResponse, error) { return client.GET("/groups/prod", nil) }, "GET", "/groups/prod"}, |
| 722 | {"create group", func() (*lib.APIResponse, error) { |
| 723 | return client.POST("/groups", []byte(`{"name":"New"}`), nil) |
| 724 | }, "POST", "/groups"}, |
| 725 | {"update group", func() (*lib.APIResponse, error) { |
| 726 | return client.PUT("/groups/prod", []byte(`{"name":"Updated"}`), nil) |
| 727 | }, "PUT", "/groups/prod"}, |
| 728 | {"delete group", func() (*lib.APIResponse, error) { return client.DELETE("/groups/prod", nil, nil) }, "DELETE", "/groups/prod"}, |
| 729 | {"pause group", func() (*lib.APIResponse, error) { return client.GET("/groups/prod/pause/4", nil) }, "GET", "/groups/prod/pause/4"}, |
| 730 | {"resume group", func() (*lib.APIResponse, error) { return client.GET("/groups/prod/pause/0", nil) }, "GET", "/groups/prod/pause/0"}, |
| 731 | } |
| 732 | |
| 733 | for _, tt := range tests { |
| 734 | t.Run(tt.name, func(t *testing.T) { |
| 735 | mock.Reset() |
| 736 | _, err := tt.do() |
| 737 | if err != nil { |
| 738 | t.Fatalf("unexpected error: %v", err) |
| 739 | } |
| 740 | req := mock.LastRequest() |
| 741 | if req.Method != tt.method { |
| 742 | t.Errorf("expected %s, got %s", tt.method, req.Method) |
| 743 | } |
| 744 | if req.Path != tt.path { |
| 745 | t.Errorf("expected %s, got %s", tt.path, req.Path) |
| 746 | } |
| 747 | }) |
| 748 | } |
| 749 | } |
| 750 | |
| 751 | func TestAPIClient_EnvironmentEndpoints(t *testing.T) { |
| 752 | mock := testutil.NewMockAPI() |
nothing calls this directly
no test coverage detected