-
Notifications
You must be signed in to change notification settings - Fork 0
/
mocks_test.go
59 lines (42 loc) · 938 Bytes
/
mocks_test.go
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
package migrate
import (
"fmt"
"github.com/golang-migrate/migrate"
)
type mockDB struct {
migrationVersion int
}
type mockMigration struct {
db mockDB
lastMigrationCall string
}
func (m *mockMigration) Up() error {
m.lastMigrationCall = "Up"
if m.db.migrationVersion == 1 {
return migrate.ErrNoChange
}
return nil
}
func (m *mockMigration) Down() error {
m.lastMigrationCall = "Down"
if m.db.migrationVersion == 0 {
return migrate.ErrNoChange
}
return nil
}
func (m *mockMigration) Drop() error {
m.lastMigrationCall = "Drop"
return nil
}
func (m *mockMigration) Force(v int) error {
m.lastMigrationCall = fmt.Sprintf("Force(%d)", v)
return nil
}
func (m *mockMigration) Version() (uint, bool, error) {
m.lastMigrationCall = "Version"
return uint(m.db.migrationVersion), false, nil
}
func (m *mockMigration) Close() (error, error) {
m.lastMigrationCall = "Close"
return nil, nil
}