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

Function TestVersionHeader_NotSentAcrossAllMethods

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

Source from the content-addressed store, hash-verified

1276}
1277
1278func TestVersionHeader_NotSentAcrossAllMethods(t *testing.T) {
1279 mock := testutil.NewMockAPI()
1280 defer mock.Close()
1281
1282 mock.SetDefault(200, `{}`)
1283
1284 viper.Set("CRONITOR_API_VERSION", "")
1285 defer viper.Set("CRONITOR_API_VERSION", "")
1286
1287 client := newTestClient(mock.Server.URL)
1288
1289 methods := []struct {
1290 name string
1291 do func() (*lib.APIResponse, error)
1292 }{
1293 {"GET", func() (*lib.APIResponse, error) { return client.GET("/test", nil) }},
1294 {"POST", func() (*lib.APIResponse, error) { return client.POST("/test", []byte(`{}`), nil) }},
1295 {"PUT", func() (*lib.APIResponse, error) { return client.PUT("/test", []byte(`{}`), nil) }},
1296 {"DELETE", func() (*lib.APIResponse, error) { return client.DELETE("/test", nil, nil) }},
1297 }
1298
1299 for _, m := range methods {
1300 t.Run(m.name, func(t *testing.T) {
1301 mock.Reset()
1302 _, err := m.do()
1303 if err != nil {
1304 t.Fatalf("unexpected error: %v", err)
1305 }
1306
1307 req := mock.LastRequest()
1308 if cv := req.Headers.Get("Cronitor-Version"); cv != "" {
1309 t.Errorf("%s: expected no Cronitor-Version header, got %q", m.name, cv)
1310 }
1311 })
1312 }
1313}
1314
1315func TestVersionHeader_ViperPriority_EnvOverridesConfig(t *testing.T) {
1316 mock := testutil.NewMockAPI()

Callers

nothing calls this directly

Calls 11

CloseMethod · 0.95
SetDefaultMethod · 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
GetMethod · 0.80

Tested by

no test coverage detected