test

package
v1.36.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 29, 2026 License: MIT Imports: 27 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TestLogLevelEnvVar = "TEST_LOG_LEVEL" // export this env var before running tests if DEBUG level is needed
	SethConfigPath     = "seth.toml"
	SettingsTarget     = "staging-settings"
)

Variables

View Source
var CLIPath = os.TempDir() + string(os.PathSeparator) + "cre" + func() string {
	if os.PathSeparator == '\\' {
		return ".exe"
	}
	return ""
}()

CLI path for testing (also defined in multi_command_flows for their use)

Functions

func ConvertSimulateBeforeAfter added in v1.1.0

func ConvertSimulateBeforeAfter(t *testing.T, projectRoot, workflowDir, workflowName, expectedSubstring string)

ConvertSimulateBeforeAfter runs simulate (capture output), convert, then simulate again and verifies output contains the same expectedSubstring. Simulate runs make build internally when needed.

func InitLogging

func InitLogging()

func LookupAndUnsetEnvVar

func LookupAndUnsetEnvVar(envVar string) string

func NewGraphQLMockServerGetOrganization added in v1.1.0

func NewGraphQLMockServerGetOrganization(t *testing.T) *httptest.Server

NewGraphQLMockServerGetOrganization starts a mock GraphQL server that responds to getCreOrganizationInfo and sets EnvVarGraphQLURL. Caller must defer srv.Close().

func RestoreEnvVar

func RestoreEnvVar(envVar string, value string)

func StartAnvil

func StartAnvil(initState AnvilInitState, stateFileName string) (*os.Process, int, error)

Boot Anvil by either loading Anvil state or running a fresh instance that will dump its state on exit Input parameter can be LOAD_ANVIL_STATE=true or DUMP_ANVIL_STATE=false (look at the defined constants)

func StopAnvil

func StopAnvil(anvilProc *os.Process)

Types

type AnvilInitState

type AnvilInitState int

needed for StartAnvil() function, describes how to boot Anvil

const (
	LOAD_ANVIL_STATE AnvilInitState = iota
	DUMP_ANVIL_STATE AnvilInitState = iota
)

type RecordedTelemetry added in v1.36.0

type RecordedTelemetry struct {
	// contains filtered or unexported fields
}

RecordedTelemetry gives thread-safe access to the reportUserEvent mutations received by NewGraphQLMockServerRecordingTelemetry. The CLI sends telemetry from a goroutine killed by os.Exit, so callers must poll Events() briefly after the CLI process exits rather than reading it immediately.

func NewGraphQLMockServerRecordingTelemetry added in v1.36.0

func NewGraphQLMockServerRecordingTelemetry(t *testing.T) (*httptest.Server, *RecordedTelemetry)

NewGraphQLMockServerRecordingTelemetry starts an httptest.Server that answers getCreOrganizationInfo/getTenantConfig like NewGraphQLMockServerGetOrganization, and additionally records every reportUserEvent mutation it receives so tests can assert telemetry was actually sent over the wire. It sets EnvVarGraphQLURL. Caller must defer srv.Close().

func (*RecordedTelemetry) Events added in v1.36.0

Events returns a snapshot of the reportUserEvent mutations received so far.

type TestConfig

type TestConfig struct {
	EnvFile              string
	WorkflowSettingsFile string
	ProjectDirectory     string
	// contains filtered or unexported fields
}

func NewTestConfig

func NewTestConfig(t *testing.T) *TestConfig

func (*TestConfig) Cleanup

func (tc *TestConfig) Cleanup(t *testing.T) func()

func (*TestConfig) GetCliEnvFlag

func (tc *TestConfig) GetCliEnvFlag() string

func (*TestConfig) GetProjectRootFlag

func (tc *TestConfig) GetProjectRootFlag() string

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL