blob: 1016334a9b698d2af790d01096b82aa78b463a54 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
|
package bolttest
import "git.eugenetriguba.com/bolt/cli/internal/models"
type MockMigrationDBRepo struct {
ListReturnValue ListReturnValue
ListCallCount int
IsAppliedReturnValue IsAppliedReturnValue
IsAppliedCallCount int
ApplyReturnValue ApplyReturnValue
ApplyCallCount int
ApplyWithTxReturnValue ApplyWithTxReturnValue
ApplyWithTxCallCount int
RevertReturnValue RevertReturnValue
RevertCallCount int
RevertWithTxReturnValue RevertWithTxReturnValue
RevertWithTxCallCount int
}
type ListReturnValue struct {
Migrations map[string]*models.Migration
Err error
}
type IsAppliedReturnValue struct {
IsApplied bool
Err error
}
type ApplyReturnValue struct {
Err error
}
type ApplyWithTxReturnValue = ApplyReturnValue
type RevertReturnValue = ApplyReturnValue
type RevertWithTxReturnValue = ApplyReturnValue
func (repo *MockMigrationDBRepo) List() (map[string]*models.Migration, error) {
repo.ListCallCount += 1
return repo.ListReturnValue.Migrations, repo.ListReturnValue.Err
}
func (repo *MockMigrationDBRepo) IsApplied(version string) (bool, error) {
repo.IsAppliedCallCount += 1
return repo.IsAppliedReturnValue.IsApplied, repo.IsAppliedReturnValue.Err
}
func (repo *MockMigrationDBRepo) Apply(
upgradeScript string,
migration *models.Migration,
) error {
repo.ApplyCallCount += 1
return repo.ApplyReturnValue.Err
}
func (repo *MockMigrationDBRepo) ApplyWithTx(
upgradeScript string,
migration *models.Migration,
) error {
repo.ApplyWithTxCallCount += 1
return repo.ApplyWithTxReturnValue.Err
}
func (repo *MockMigrationDBRepo) Revert(
downgradeScript string,
migration *models.Migration,
) error {
repo.RevertCallCount += 1
return repo.RevertReturnValue.Err
}
func (repo *MockMigrationDBRepo) RevertWithTx(
downgradeScript string,
migration *models.Migration,
) error {
repo.RevertWithTxCallCount += 1
return repo.RevertWithTxReturnValue.Err
}
|