-
Notifications
You must be signed in to change notification settings - Fork 0
/
config_test.go
58 lines (52 loc) · 1.24 KB
/
config_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
package igmigrator
import (
"fmt"
"testing"
"github.com/stretchr/testify/assert"
)
func TestConfig_SetDefaults(t *testing.T) {
tests := []struct {
Input Config
Validate func(t *testing.T, cnf Config)
}{
{
Input: Config{Schema: " "},
Validate: func(t *testing.T, cnf Config) {
assert.Equal(t, "", cnf.Schema)
},
},
{
Input: Config{Schema: " asdd ad "},
Validate: func(t *testing.T, cnf Config) {
assert.Equal(t, "asddad", cnf.Schema)
},
},
{
Input: Config{MigrationTable: " "},
Validate: func(t *testing.T, cnf Config) {
assert.Equal(t, "migration", cnf.MigrationTable)
},
},
{
Input: Config{MigrationTable: " aaa_ss4 !!"},
Validate: func(t *testing.T, cnf Config) {
assert.Equal(t, "aaa_ss4", cnf.MigrationTable)
},
},
{
// No validations are done on input migration directory.
// If it is invalid - error will be returned anyhow.
Input: Config{MigrationsDir: "/aa_a187&*%*3/aa a/"},
Validate: func(t *testing.T, cnf Config) {
assert.Equal(t, "/aa_a187&*%*3/aa a/", cnf.MigrationsDir)
},
},
}
for i := range tests {
test := tests[i]
t.Run(fmt.Sprintf("%d", i), func(t *testing.T) {
test.Input.SetDefaults()
test.Validate(t, test.Input)
})
}
}