scenario

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: May 18, 2026 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Result

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

Result holds the outcome of a scenario execution step.

func (*Result) AssertApplied

func (r *Result) AssertApplied(n int) *Result

AssertApplied asserts the number of migrations applied.

func (*Result) AssertError

func (r *Result) AssertError(substring string) *Result

AssertError checks the error message contains a substring.

func (*Result) AssertErrors added in v0.3.0

func (r *Result) AssertErrors(n int) *Result

AssertErrors checks the number of validation errors.

func (*Result) AssertExitCode

func (r *Result) AssertExitCode(code int) *Result

AssertExitCode checks the exit code.

func (*Result) AssertFileExists

func (r *Result) AssertFileExists(fileKey string) *Result

AssertFileExists checks the file exists on disk.

func (*Result) AssertFileNotExists

func (r *Result) AssertFileNotExists(fileKey string) *Result

AssertFileNotExists checks the file does NOT exist on disk.

func (*Result) AssertHasKey

func (r *Result) AssertHasKey(fileKey, path string) *Result

AssertHasKey checks a key exists.

func (*Result) AssertKey

func (r *Result) AssertKey(fileKey, path string, expected any) *Result

AssertKey checks a TOML key's value at a dot-path.

func (*Result) AssertMissingKey

func (r *Result) AssertMissingKey(fileKey, path string) *Result

AssertMissingKey checks a key does NOT exist.

func (*Result) AssertOutputExists added in v0.3.0

func (r *Result) AssertOutputExists() *Result

AssertOutputExists checks that the merge output file exists on disk.

func (*Result) AssertPathExists added in v0.3.0

func (r *Result) AssertPathExists(rel string) *Result

AssertPathExists checks that a path relative to the scenario dir exists.

func (*Result) AssertPending

func (r *Result) AssertPending(n int) *Result

AssertPending checks the number of pending migrations (for Status results).

func (*Result) AssertSuccess

func (r *Result) AssertSuccess() *Result

AssertSuccess asserts no error.

func (*Result) AssertUntouched

func (r *Result) AssertUntouched(fileKey string) *Result

AssertUntouched checks file content is unchanged from before the step.

func (*Result) AssertVersion

func (r *Result) AssertVersion(fileKey, version string) *Result

AssertVersion checks _schema_version in a file.

func (*Result) AssertWarnings added in v0.3.0

func (r *Result) AssertWarnings(n int) *Result

AssertWarnings checks the number of validation warnings.

type Scenario

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

Scenario represents an isolated migration test environment.

func New

func New(t *testing.T) *Scenario

New creates a scenario with an isolated temp directory.

func (*Scenario) Env

func (s *Scenario) Env(key, value string) *Scenario

Env sets an environment variable (restored after test).

func (*Scenario) Init added in v0.3.0

func (s *Scenario) Init() *Result

Init runs engine.Init on the scenario directory.

func (*Scenario) Input

func (s *Scenario) Input(fileKey, tomlContent string) *Scenario

Input writes initial content for a file key.

func (*Scenario) Merge added in v0.3.0

func (s *Scenario) Merge(version string) *Result

Merge runs engine.Merge on the migrations directory with the given version.

func (*Scenario) Migrate

func (s *Scenario) Migrate() *Result

Migrate runs forward migration.

func (*Scenario) MigrateDryRun

func (s *Scenario) MigrateDryRun() *Result

MigrateDryRun runs migration in dry-run mode.

func (*Scenario) Migration

func (s *Scenario) Migration(version, content string) *Scenario

Migration places a migration file in the migrations directory.

func (*Scenario) MultiFile

func (s *Scenario) MultiFile(files map[string]string, versionFile string) *Scenario

MultiFile configures a multi-file project.

func (*Scenario) Rollback

func (s *Scenario) Rollback() *Result

Rollback rolls back the last applied migration.

func (*Scenario) RollbackDryRun

func (s *Scenario) RollbackDryRun() *Result

RollbackDryRun runs rollback in dry-run mode.

func (*Scenario) SingleFile

func (s *Scenario) SingleFile(fileKey, relativePath string) *Scenario

SingleFile configures a single-file project.

func (*Scenario) StagingFile added in v0.3.0

func (s *Scenario) StagingFile(name, content string) *Scenario

StagingFile writes a staging file to migrations/next/<name>.toml.

func (*Scenario) Status

func (s *Scenario) Status() *Result

Status computes current migration status.

func (*Scenario) Validate added in v0.3.0

func (s *Scenario) Validate() *Result

Validate runs engine.Validate on the migrations directory.

Jump to

Keyboard shortcuts

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