{"modulePath":"github.com/newstack-cloud/celerity/apps/cli","version":"v0.0.0-20261125230728-bf62912a2d4e","isLatest":true,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package testutils\n\n## Functions\n\n```go\nfunc LoadTestBlueprint(t *testing.T, yamlContent string) *schema.Blueprint\n```\nLoadTestBlueprint loads a blueprint from a YAML string, failing the test on error.\n\n```go\nfunc RequireEnv(t *testing.T, envVar string) string\n```\nRequireEnv skips the test if the given environment variable is not set or the endpoint it points to is not reachable. Returns the value if present and reachable.\n\n## Types\n\n```go\ntype ExecSQLCall struct {\n\tDatabaseName string\n\tSQL          string\n}\n```\nExecSQLCall records a single ExecSQL invocation.\n\n```go\ntype MockDeployEngine struct {\n\tCreateBlueprintValidationResult *manage.BlueprintValidation\n\tCreateBlueprintValidationErr    error\n\n\tGetBlueprintValidationResult *manage.BlueprintValidation\n\tGetBlueprintValidationErr    error\n\n\t// StreamBlueprintValidationEventsFn allows full control over the streaming behaviour.\n\t// If set, it is called directly; otherwise the default implementation\n\t// sends StubValidationEvents to the streamTo channel and then closes it.\n\tStreamBlueprintValidationEventsFn func(ctx context.Context, validationID string, lastEventID string, streamTo chan\u003c- types.BlueprintValidationEvent, errChan chan\u003c- error) error\n\tStreamBlueprintValidationErr      error\n\tStubValidationEvents              []types.BlueprintValidationEvent\n\n\tCreateChangesetResult *manage.Changeset\n\tCreateChangesetErr    error\n\n\tGetChangesetResult *manage.Changeset\n\tGetChangesetErr    error\n\n\tStreamChangeStagingEventsFn func(ctx context.Context, changesetID string, lastEventID string, streamTo chan\u003c- types.ChangeStagingEvent, errChan chan\u003c- error) error\n\tStreamChangeStagingErr      error\n\n\tCreateBlueprintInstanceResult *state.InstanceState\n\tCreateBlueprintInstanceErr    error\n\n\tUpdateBlueprintInstanceResult *state.InstanceState\n\tUpdateBlueprintInstanceErr    error\n\n\tGetBlueprintInstanceResult *state.InstanceState\n\tGetBlueprintInstanceErr    error\n\n\tListBlueprintInstancesResult state.ListInstancesResult\n\tListBlueprintInstancesErr    error\n\n\tGetBlueprintInstanceExportsResult map[string]*state.ExportState\n\tGetBlueprintInstanceExportsErr    error\n\n\tDestroyBlueprintInstanceResult *state.InstanceState\n\tDestroyBlueprintInstanceErr    error\n\n\tStreamBlueprintInstanceEventsFn func(ctx context.Context, instanceID string, lastEventID string, streamTo chan\u003c- types.BlueprintInstanceEvent, errChan chan\u003c- error) error\n\tStreamBlueprintInstanceErr      error\n\n\t// LastEventID is returned on every create and destroy response, so a test\n\t// can assert that it reaches the stream call that should carry it.\n\tLastEventID string\n\n\tCleanupOperationResult *manage.CleanupOperation\n\tCleanupErr             error\n\n\tApplyReconciliationResult *container.ApplyReconciliationResult\n\tApplyReconciliationErr    error\n}\n```\nMockDeployEngine is a test double for engine.DeployEngine. Set the fields to control return values and inject errors.\n\nThe create and destroy calls answer with a response wrapper carrying a LastEventID alongside the resource, because that is what the engine returns and what a caller has to pass on to the matching stream call. The \\*Result fields hold the resource, and the wrapper is built around it, so a test setting one does not have to know the wrapper exists.\n\n```go\nfunc (m *MockDeployEngine) ApplyReconciliation(\n\t_ context.Context,\n\t_ string,\n\t_ *types.ApplyReconciliationPayload,\n) (*container.ApplyReconciliationResult, error)\n```\n\n```go\nfunc (m *MockDeployEngine) CleanupBlueprintValidations(_ context.Context) (*manage.CleanupOperation, error)\n```\n\n```go\nfunc (m *MockDeployEngine) CleanupChangesets(_ context.Context) (*manage.CleanupOperation, error)\n```\n\n```go\nfunc (m *MockDeployEngine) CleanupEvents(_ context.Context) (*manage.CleanupOperation, error)\n```\n\n```go\nfunc (m *MockDeployEngine) CleanupReconciliationResults(_ context.Context) (*manage.CleanupOperation, error)\n```\n\n```go\nfunc (m *MockDeployEngine) CreateBlueprintInstance(\n\t_ context.Context,\n\t_ *types.BlueprintInstancePayload,\n) (*types.BlueprintInstanceResponse, error)\n```\n\n```go\nfunc (m *MockDeployEngine) CreateBlueprintValidation(\n\t_ context.Context,\n\t_ *types.CreateBlueprintValidationPayload,\n\t_ *types.CreateBlueprintValidationQuery,\n) (*types.BlueprintValidationResponse, error)\n```\n\n```go\nfunc (m *MockDeployEngine) CreateChangeset(\n\t_ context.Context,\n\t_ *types.CreateChangesetPayload,\n) (*types.ChangesetResponse, error)\n```\n\n```go\nfunc (m *MockDeployEngine) DestroyBlueprintInstance(\n\t_ context.Context,\n\t_ string,\n\t_ *types.DestroyBlueprintInstancePayload,\n) (*types.BlueprintInstanceResponse, error)\n```\n\n```go\nfunc (m *MockDeployEngine) GetBlueprintInstance(_ context.Context, _ string) (*state.InstanceState, error)\n```\n\n```go\nfunc (m *MockDeployEngine) GetBlueprintInstanceExports(_ context.Context, _ string) (map[string]*state.ExportState, error)\n```\n\n```go\nfunc (m *MockDeployEngine) GetBlueprintValidation(_ context.Context, _ string) (*manage.BlueprintValidation, error)\n```\n\n```go\nfunc (m *MockDeployEngine) GetChangeset(_ context.Context, _ string) (*manage.Changeset, error)\n```\n\n```go\nfunc (m *MockDeployEngine) GetCleanupOperation(\n\t_ context.Context,\n\t_ manage.CleanupType,\n\t_ string,\n) (*manage.CleanupOperation, error)\n```\n\n```go\nfunc (m *MockDeployEngine) ListBlueprintInstances(\n\t_ context.Context,\n\t_ state.ListInstancesParams,\n) (state.ListInstancesResult, error)\n```\n\n```go\nfunc (m *MockDeployEngine) StreamBlueprintInstanceEvents(\n\tctx context.Context,\n\tinstanceID string,\n\tlastEventID string,\n\tstreamTo chan\u003c- types.BlueprintInstanceEvent,\n\terrChan chan\u003c- error,\n) error\n```\n\n```go\nfunc (m *MockDeployEngine) StreamBlueprintValidationEvents(\n\tctx context.Context,\n\tvalidationID string,\n\tlastEventID string,\n\tstreamTo chan\u003c- types.BlueprintValidationEvent,\n\terrChan chan\u003c- error,\n) error\n```\n\n```go\nfunc (m *MockDeployEngine) StreamChangeStagingEvents(\n\tctx context.Context,\n\tchangesetID string,\n\tlastEventID string,\n\tstreamTo chan\u003c- types.ChangeStagingEvent,\n\terrChan chan\u003c- error,\n) error\n```\n\n```go\nfunc (m *MockDeployEngine) UpdateBlueprintInstance(\n\t_ context.Context,\n\t_ string,\n\t_ *types.BlueprintInstancePayload,\n) (*types.BlueprintInstanceResponse, error)\n```\n\n```go\nfunc (m *MockDeployEngine) WaitForCleanupCompletion(\n\t_ context.Context,\n\t_ manage.CleanupType,\n\t_ string,\n\t_ time.Duration,\n) (*manage.CleanupOperation, error)\n```\n\n```go\ntype MockDockerManager struct {\n\tCheckAvailabilityFn func(ctx context.Context) error\n\tEnsureImageFn       func(ctx context.Context, image string, progress chan\u003c- docker.ImagePullProgress) error\n\tCreateAndStartFn    func(ctx context.Context, config *docker.ContainerConfig) (string, error)\n\tStreamLogsFn        func(ctx context.Context, containerID string) (io.ReadCloser, error)\n\tStreamLogsOptsFn    func(ctx context.Context, containerID string, opts docker.LogStreamOptions) (io.ReadCloser, error)\n\tRestartContainerFn  func(ctx context.Context, containerID string) error\n\tStopFn              func(ctx context.Context, containerID string) error\n\tIsRunningFn         func(ctx context.Context, containerID string) (bool, error)\n\tCleanupStaleFn      func(ctx context.Context, containerName string) error\n\n\t// Call records for assertions.\n\tStopCalls         []string\n\tCleanupStaleCalls []string\n}\n```\nMockDockerManager is a test double for docker.RuntimeContainerManager. Set the function fields to control behaviour; unset fields return nil/zero.\n\n```go\nfunc (m *MockDockerManager) CheckAvailability(ctx context.Context) error\n```\n\n```go\nfunc (m *MockDockerManager) CleanupStale(ctx context.Context, containerName string) error\n```\n\n```go\nfunc (m *MockDockerManager) CreateAndStart(ctx context.Context, config *docker.ContainerConfig) (string, error)\n```\n\n```go\nfunc (m *MockDockerManager) EnsureImage(ctx context.Context, image string, progress chan\u003c- docker.ImagePullProgress) error\n```\n\n```go\nfunc (m *MockDockerManager) IsRunning(ctx context.Context, containerID string) (bool, error)\n```\n\n```go\nfunc (m *MockDockerManager) RestartContainer(ctx context.Context, containerID string) error\n```\n\n```go\nfunc (m *MockDockerManager) Stop(ctx context.Context, containerID string) error\n```\n\n```go\nfunc (m *MockDockerManager) StreamLogs(ctx context.Context, containerID string) (io.ReadCloser, error)\n```\n\n```go\nfunc (m *MockDockerManager) StreamLogsWithOptions(ctx context.Context, containerID string, opts docker.LogStreamOptions) (io.ReadCloser, error)\n```\n\n```go\ntype MockNoSQLSeeder struct {\n\tPutItemCalls []PutItemCall\n\tPutItemErr   error\n}\n```\nMockNoSQLSeeder records all PutItem calls for assertion.\n\n```go\nfunc (m *MockNoSQLSeeder) PutItem(_ context.Context, tableName string, itemJSON []byte) error\n```\n\n```go\ntype MockSQLSeeder struct {\n\tExecSQLCalls []ExecSQLCall\n\tExecSQLErr   error\n}\n```\nMockSQLSeeder records all ExecSQL calls for assertion.\n\n```go\nfunc (m *MockSQLSeeder) ExecSQL(_ context.Context, databaseName string, sql string) error\n```\n\n```go\ntype MockStorageUploader struct {\n\tUploadCalls []UploadCall\n\tUploadErr   error\n}\n```\nMockStorageUploader records all Upload calls for assertion.\n\n```go\nfunc (m *MockStorageUploader) Upload(_ context.Context, bucketName string, objectKey string, data []byte) error\n```\n\n```go\ntype PutItemCall struct {\n\tTableName string\n\tItemJSON  []byte\n}\n```\nPutItemCall records a single PutItem invocation.\n\n```go\ntype UploadCall struct {\n\tBucketName string\n\tObjectKey  string\n\tData       []byte\n}\n```\nUploadCall records a single Upload invocation.\n\n","path":"github.com/newstack-cloud/celerity/apps/cli/internal/testutils","name":"testutils","synopsis":"","isRedistributable":true}
