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

Function TestAPIClient_PUT

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

Source from the content-addressed store, hash-verified

134}
135
136func TestAPIClient_PUT(t *testing.T) {
137 mock := testutil.NewMockAPI()
138 defer mock.Close()
139
140 mock.On("PUT", "/groups/prod", 200, `{"key":"prod","name":"Updated"}`)
141
142 client := newTestClient(mock.Server.URL)
143 body := []byte(`{"name":"Updated"}`)
144 resp, err := client.PUT("/groups/prod", body, nil)
145 if err != nil {
146 t.Fatalf("unexpected error: %v", err)
147 }
148
149 if resp.StatusCode != 200 {
150 t.Errorf("expected status 200, got %d", resp.StatusCode)
151 }
152
153 req := mock.LastRequest()
154 if req.Method != "PUT" {
155 t.Errorf("expected PUT, got %s", req.Method)
156 }
157 if req.Path != "/groups/prod" {
158 t.Errorf("expected /groups/prod, got %s", req.Path)
159 }
160}
161
162func TestAPIClient_DELETE(t *testing.T) {
163 mock := testutil.NewMockAPI()

Callers

nothing calls this directly

Calls 6

CloseMethod · 0.95
OnMethod · 0.95
LastRequestMethod · 0.95
NewMockAPIFunction · 0.92
newTestClientFunction · 0.85
PUTMethod · 0.80

Tested by

no test coverage detected