diff options
| author | Eugene Triguba <eugenetriguba@gmail.com> | 2024-03-02 11:07:30 -0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-03-02 11:07:30 -0500 |
| commit | 571bc9bf2efa841b29bf036f4d307664bfbe155d (patch) | |
| tree | 41fb3a459db99d1f0ec2ed2e00d4ca580a5d0c46 /internal/bolttest/mock_migration_fs_repo.go | |
| parent | Update readme (diff) | |
| parent | Remove Latest() from migration fs repo in favor of using List on service (diff) | |
| download | cli-571bc9bf2efa841b29bf036f4d307664bfbe155d.zip | |
Merge pull request #1 from eugenetriguba/0.3.0
Diffstat (limited to 'internal/bolttest/mock_migration_fs_repo.go')
| -rw-r--r-- | internal/bolttest/mock_migration_fs_repo.go | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/internal/bolttest/mock_migration_fs_repo.go b/internal/bolttest/mock_migration_fs_repo.go new file mode 100644 index 0000000..d392732 --- /dev/null +++ b/internal/bolttest/mock_migration_fs_repo.go @@ -0,0 +1,49 @@ +package bolttest + +import "github.com/eugenetriguba/bolt/internal/models" + +type MockMigrationFsRepo struct { + CreateReturnValue CreateReturnValue + CreateCallCount int + ListReturnValue ListReturnValue + ListCallCount int + ReadUpgradeScriptReturnValue ReadUpgradeScriptReturnValue + ReadUpgradeScriptCallCount int + ReadDowngradeScriptReturnValue ReadDowngradeScriptReturnValue + ReadDowngradeScriptCallCount int +} + +type CreateReturnValue struct { + Err error +} + +type ReadUpgradeScriptReturnValue struct { + ScriptContents string + Err error +} + +type ReadDowngradeScriptReturnValue = ReadUpgradeScriptReturnValue + +func (repo *MockMigrationFsRepo) Create(migration *models.Migration) error { + repo.CreateCallCount += 1 + return repo.CreateReturnValue.Err +} + +func (repo *MockMigrationFsRepo) List() (map[string]*models.Migration, error) { + repo.ListCallCount += 1 + return repo.ListReturnValue.Migrations, repo.ListReturnValue.Err +} + +func (repo *MockMigrationFsRepo) ReadUpgradeScript( + migration *models.Migration, +) (string, error) { + repo.ReadUpgradeScriptCallCount += 1 + return repo.ReadUpgradeScriptReturnValue.ScriptContents, repo.ReadUpgradeScriptReturnValue.Err +} + +func (repo *MockMigrationFsRepo) ReadDowngradeScript( + migration *models.Migration, +) (string, error) { + repo.ReadDowngradeScriptCallCount += 1 + return repo.ReadDowngradeScriptReturnValue.ScriptContents, repo.ReadDowngradeScriptReturnValue.Err +} |