Documentation
¶
Index ¶
- func IntegrationEnabled() bool
- func RequireIntegration(t testing.TB)
- func RequireNoError(t testing.TB, err error)
- func RequireNotEmpty(t testing.TB, s string)
- func RunCommandCaptureOutput(command *cobra.Command, args []string) (string, error)
- func RunWithMockServer(handler http.HandlerFunc, viperOverrides map[string]any, cmd *cobra.Command, ...) (string, error)
- func RunWithSimpleGraphQL(mockData any, cmd *cobra.Command, args []string) (string, error)
- func StartMockServer(handler http.HandlerFunc) (string, func())
- func WithViper(overrides map[string]any) func()
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func IntegrationEnabled ¶
func IntegrationEnabled() bool
IntegrationEnabled returns true when integration tests are enabled via the NUDGEBEE_INTEGRATION env var.
func RequireIntegration ¶
RequireIntegration checks environment and calls t.Skip when integration tests should not run. It also initializes config so viper reads env vars.
func RequireNoError ¶
RequireNoError fails the test if err is non-nil.
func RequireNotEmpty ¶
RequireNotEmpty fails the test if s is empty.
func RunCommandCaptureOutput ¶
RunCommandCaptureOutput runs a cobra command and returns its stdout output as a string and an error from the command.
func RunWithMockServer ¶
func RunWithMockServer(handler http.HandlerFunc, viperOverrides map[string]any, cmd *cobra.Command, args []string) (string, error)
RunWithMockServer starts an httptest server with handler, applies viper overrides, runs the provided cobra command, and tears down everything. It returns the captured output and any error from running the command.
func RunWithSimpleGraphQL ¶
RunWithSimpleGraphQL is a convenience helper that starts a mock server which automatically handles the token endpoint and serves the provided mockData as the GraphQL response payload under the "data" field. It's suitable for the common case where tests only need to mock returned data.
func StartMockServer ¶
func StartMockServer(handler http.HandlerFunc) (string, func())
StartMockServer starts an httptest.Server with the provided handler and returns its URL and a teardown function.
Types ¶
This section is empty.