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

Function TestVersionHeader_NotSentWhenUnset

lib/api_client_test.go:1171–1190  ·  view source on GitHub ↗

--- Phase 5f: Configuration & Version Header Tests ---

(t *testing.T)

Source from the content-addressed store, hash-verified

1169// --- Phase 5f: Configuration & Version Header Tests ---
1170
1171func TestVersionHeader_NotSentWhenUnset(t *testing.T) {
1172 mock := testutil.NewMockAPI()
1173 defer mock.Close()
1174
1175 mock.On("GET", "/monitors", 200, `{}`)
1176
1177 viper.Set("CRONITOR_API_VERSION", "")
1178 defer viper.Set("CRONITOR_API_VERSION", "")
1179
1180 client := newTestClient(mock.Server.URL)
1181 _, err := client.GET("/monitors", nil)
1182 if err != nil {
1183 t.Fatalf("unexpected error: %v", err)
1184 }
1185
1186 req := mock.LastRequest()
1187 if cv := req.Headers.Get("Cronitor-Version"); cv != "" {
1188 t.Errorf("expected no Cronitor-Version header when unset, got %q", cv)
1189 }
1190}
1191
1192func TestVersionHeader_SentWhenConfigured(t *testing.T) {
1193 mock := testutil.NewMockAPI()

Callers

nothing calls this directly

Calls 7

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

Tested by

no test coverage detected