setupIntegrationTest configures the test environment to point at a mock server. It returns a cleanup function that restores the original state.
(mockURL string)
| 18 | // setupIntegrationTest configures the test environment to point at a mock server. |
| 19 | // It returns a cleanup function that restores the original state. |
| 20 | func 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. |
| 36 | func executeCmd(args ...string) (string, error) { |
no outgoing calls
no test coverage detected