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

Function TestVersionHeader_DifferentVersionValues

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

Source from the content-addressed store, hash-verified

1211}
1212
1213func TestVersionHeader_DifferentVersionValues(t *testing.T) {
1214 mock := testutil.NewMockAPI()
1215 defer mock.Close()
1216
1217 mock.On("GET", "/monitors", 200, `{}`)
1218
1219 versions := []string{"2020-10-01", "2025-11-28", "2026-01-01"}
1220 for _, version := range versions {
1221 t.Run(version, func(t *testing.T) {
1222 mock.Reset()
1223 viper.Set("CRONITOR_API_VERSION", version)
1224 defer viper.Set("CRONITOR_API_VERSION", "")
1225
1226 client := newTestClient(mock.Server.URL)
1227 _, err := client.GET("/monitors", nil)
1228 if err != nil {
1229 t.Fatalf("unexpected error: %v", err)
1230 }
1231
1232 req := mock.LastRequest()
1233 if cv := req.Headers.Get("Cronitor-Version"); cv != version {
1234 t.Errorf("expected Cronitor-Version %q, got %q", version, cv)
1235 }
1236 })
1237 }
1238}
1239
1240func TestVersionHeader_AppliesAcrossAllMethods(t *testing.T) {
1241 mock := testutil.NewMockAPI()

Callers

nothing calls this directly

Calls 8

CloseMethod · 0.95
OnMethod · 0.95
ResetMethod · 0.95
LastRequestMethod · 0.95
NewMockAPIFunction · 0.92
newTestClientFunction · 0.85
GETMethod · 0.80
GetMethod · 0.80

Tested by

no test coverage detected