Documentation ¶
Index ¶
- func AssertBumpedVersion(t *testing.T, newRepoDir, oldRepoDir string, oldVersion uint64)
- func AssertLinked(t *testing.T, repoDir, repoLink string)
- func AssertLogged(t *testing.T, logFile *os.File, subStr string)
- func AssertNewRepoInstalled(t *testing.T, newRepoDir, oldRepoDir, repoLink string)
- func AssertRepoVersion(t *testing.T, versionStr, repoPath string)
- func CloneRepo(linkPath string, newVersion uint) (string, error)
- func InstallNewRepo(linkPath, newRepoPath string) error
- func RequireInitRepo(t *testing.T, version uint) (container, repoLink string)
- type Logger
- type Migration
- type MigrationRunner
- type RunResult
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AssertBumpedVersion ¶
AssertBumpedVersion checks that the version oldRepoDir is as expected, that the version in newRepoDir is updated by 1
func AssertLinked ¶
AssertLinked verifies that repoLink points to oldRepoDir
func AssertLogged ¶
AssertLogged asserts that a given string is contained in the given log file.
func AssertNewRepoInstalled ¶
AssertNewRepoInstalled verifies that the repoLink points to newRepoDir, and that oldRepoDir is still there
func AssertRepoVersion ¶
AssertRepoVersion verifies that the version in repoPath is equal to versionStr
func CloneRepo ¶
CloneRepo copies a linked repo directory to a new, writable repo directory. The directory created will be named with a timestamp, version number, and uniqueifyig tag if necessary.
Params:
linkPath: path to a symlink, which links to an actual repo directory to be cloned.
func InstallNewRepo ¶
InstallNewRepo updates a symlink to point to a new repo directory.
func RequireInitRepo ¶
RequireInitRepo establishes a new repo symlink and directory inside a temporary container directory. Migrations of the repo are expected to be placed within the same container, such that a test can clean up arbitrary migrations by removing the container. Returns the path to the container directory, and the repo symlink inside it.
Types ¶
type Logger ¶
type Logger struct {
// contains filtered or unexported fields
}
Logger logs migration events to disk and, if initialized with verbose, stdout too.
func NewLogger ¶
func NewLogger(wc io.WriteCloser, verbose bool) *Logger
NewLogger creates a new Logger. All log writes go to f, the logging file. If the verbose flag is true all log writes also go to stdout.
type Migration ¶
type Migration interface { // Describe returns a list of steps, as a formatted string, that a given Migration will take. // These should correspond to named functions in the given Migration. Describe() string // Migrate performs all migration steps for the Migration that implements the interface. // Migrate expects newRepo to be: // a directory // read/writeable by this process, // contain a copy of the old repo. Migrate(newRepoPath string) error // Versions returns valid from and to migration versions for this migration. Versions() (from, to uint) // Validate performs validation operations, using oldRepo for comparison. // Validation requirements will be different for every migration. // Validate expects newRepo to be // a directory // readable by this process // already migrated // It expects oldRepo to be // a directory // read-only by this process // A successful validation returns nil. Validate(oldRepoPath, newRepoPath string) error }
Migration is the interface to all repo migration versions.
func DefaultMigrationsProvider ¶
func DefaultMigrationsProvider() []Migration
DefaultMigrationsProvider is the migrations provider dependency used in production. You may provide a test version when needed. Please see runner_test.go for more information.
type MigrationRunner ¶
type MigrationRunner struct { // MigrationsProvider is a dependency for fetching available migrations // to allow unit tests to supply test migrations without creating test fixtures. MigrationsProvider func() []Migration // contains filtered or unexported fields }
MigrationRunner represents a migration command
func NewMigrationRunner ¶
func NewMigrationRunner(logger *Logger, command, oldRepoOpt, newRepoOpt string) (*MigrationRunner, error)
NewMigrationRunner builds a MigrationRunner for the given command and repo options Returns an error if homepath expansion fails for oldRepoOpt or newRepoOpt
func (*MigrationRunner) Run ¶
func (m *MigrationRunner) Run() RunResult
Run executes the MigrationRunner
type RunResult ¶
type RunResult struct { // full path to new repo (migrated or not). // This is blank unless repo was cloned -- if it errors out too early or for "describe" NewRepoPath string // Old version and new version. If no applicable migration is found, these will be equal, // and if errors early they will = 0. OldVersion, NewVersion uint // Any errors encountered by Run Err error }
RunResult stores the needed results of calling Run()