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

Function TestAPIClient_GroupEndpoints

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

Source from the content-addressed store, hash-verified

707}
708
709func 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
751func TestAPIClient_EnvironmentEndpoints(t *testing.T) {
752 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