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

Function setupIntegrationTest

cmd/integration_test.go:20–33  ·  view source on GitHub ↗

setupIntegrationTest configures the test environment to point at a mock server. It returns a cleanup function that restores the original state.

(mockURL string)

Source from the content-addressed store, hash-verified

18// setupIntegrationTest configures the test environment to point at a mock server.
19// It returns a cleanup function that restores the original state.
20func setupIntegrationTest(mockURL string) func() {
21 oldBaseURL := lib.BaseURLOverride
22 oldAPIKey := viper.GetString("CRONITOR_API_KEY")
23
24 lib.BaseURLOverride = mockURL
25 viper.Set("CRONITOR_API_KEY", "test-api-key-1234567890")
26 viper.Set("CRONITOR_API_VERSION", "")
27
28 return func() {
29 lib.BaseURLOverride = oldBaseURL
30 viper.Set("CRONITOR_API_KEY", oldAPIKey)
31 viper.Set("CRONITOR_API_VERSION", "")
32 }
33}
34
35// executeCmd runs a command through the root cobra command and captures stdout.
36func executeCmd(args ...string) (string, error) {

Calls

no outgoing calls

Tested by

no test coverage detected