blob: 1d73ca492a013744186df2c7290cfbdf4be40029 (
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
|
package bolttest
import "git.sr.ht/~eugenetriguba/bolt/internal/models"
type MockMigrationDependencyGraph struct {
TopologicalSortReturnValue TopologicalSortReturnValue
TopologicalSortCallCount int
ReverseTopologicalSortReturnValue ReverseTopologicalSortReturnValue
ReverseTopologicalSortCallCount int
CheckDependenciesAppliedReturnValue CheckDependenciesAppliedReturnValue
CheckDependenciesAppliedCallCount int
CheckNoDependentsAppliedReturnValue CheckNoDependentsAppliedReturnValue
CheckNoDependentsAppliedCallCount int
FindLeafNodesReturnValue FindLeafNodesReturnValue
FindLeafNodesCallCount int
}
type TopologicalSortReturnValue struct {
Migrations []*models.Migration
Err error
}
type ReverseTopologicalSortReturnValue = TopologicalSortReturnValue
type CheckDependenciesAppliedReturnValue struct {
Err error
}
type CheckNoDependentsAppliedReturnValue = CheckDependenciesAppliedReturnValue
type FindLeafNodesReturnValue struct {
LeafNodes []string
Err error
}
func (g *MockMigrationDependencyGraph) TopologicalSort(migrations []*models.Migration) ([]*models.Migration, error) {
g.TopologicalSortCallCount++
return g.TopologicalSortReturnValue.Migrations, g.TopologicalSortReturnValue.Err
}
func (g *MockMigrationDependencyGraph) ReverseTopologicalSort(migrations []*models.Migration) ([]*models.Migration, error) {
g.ReverseTopologicalSortCallCount++
return g.ReverseTopologicalSortReturnValue.Migrations, g.ReverseTopologicalSortReturnValue.Err
}
func (g *MockMigrationDependencyGraph) CheckDependenciesApplied(
migration *models.Migration,
allMigrations []*models.Migration,
) error {
g.CheckDependenciesAppliedCallCount++
return g.CheckDependenciesAppliedReturnValue.Err
}
func (g *MockMigrationDependencyGraph) CheckNoDependentsApplied(
migration *models.Migration,
allMigrations []*models.Migration,
) error {
g.CheckNoDependentsAppliedCallCount++
return g.CheckNoDependentsAppliedReturnValue.Err
}
func (g *MockMigrationDependencyGraph) FindLeafNodes(localMigrations map[string]*models.Migration) ([]string, error) {
g.FindLeafNodesCallCount++
return g.FindLeafNodesReturnValue.LeafNodes, g.FindLeafNodesReturnValue.Err
}
|