-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfile_test.go
58 lines (53 loc) · 1.33 KB
/
file_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 gograte_test
import (
"testing"
"github.com/Shin-Thant/gograte"
)
func TestValidateMigrationFilePaths(t *testing.T) {
mockPaths := []string{
"migrations/0001_create_table.sql",
"migrations/0002_create_table.sql",
"migrations/0003_create_table.sql",
}
result := gograte.ValidateMigrationFilePaths(mockPaths)
if len(mockPaths) != len(result) {
t.Errorf("Expected %d, got %d", len(mockPaths), len(result))
}
for _, m := range result {
if m.Timestamp == 0 {
t.Errorf("Expected timestamp to be non-zero")
}
if m.Name == "" {
t.Errorf("Expected name to be non-empty")
}
if m.Path == "" {
t.Errorf("Expected path to be non-empty")
}
if m.IsNewFile {
t.Errorf("Expected IsNewFile to be false")
}
}
mockPaths = []string{
"migrations/0001_create_table.sql",
"migrations/0002_create_table.sql",
"migrations/create_table.sql",
}
result = gograte.ValidateMigrationFilePaths(mockPaths)
if len(mockPaths)-1 != len(result) {
t.Errorf("Expected %d, got %d", len(mockPaths)-1, len(result))
}
for _, m := range result {
if m.Timestamp == 0 {
t.Errorf("Expected timestamp to be non-zero")
}
if m.Name == "" {
t.Errorf("Expected name to be non-empty")
}
if m.Path == "" {
t.Errorf("Expected path to be non-empty")
}
if m.IsNewFile {
t.Errorf("Expected IsNewFile to be false")
}
}
}