-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcmp_test.go
59 lines (55 loc) · 1.57 KB
/
cmp_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 sumdiff
import (
"github.com/stretchr/testify/assert"
"testing"
)
func TestCmpFile(t *testing.T) {
for _, v := range []struct {
expected bool
path1 string
path2 string
}{
{true, "./test_data/a.txt", "./test_data/b.txt"},
{false, "./test_data/a.txt", "./test_data/c.txt"},
{false, "./test_data/a.txt", "./test_data/d.txt"},
{false, "./test_data/c.txt", "./test_data/d.txt"},
} {
ok, _, err := CmpFile(v.path1, v.path2)
assert.NoError(t, err)
assert.Equal(t, v.expected, ok, "Error at %v|%v", v.path1, v.path2)
}
}
func TestCmpDir(t *testing.T) {
for _, v := range []struct {
expected bool
path1 string
path2 string
}{
{true, "./test_data/data1", "./test_data/data2"},
{false, "./test_data/data1", "./test_data/data3"},
{false, "./test_data/data1", "./test_data/data4"},
} {
ok, _, err := CmpDir(v.path1, v.path2)
assert.NoError(t, err)
assert.Equal(t, v.expected, ok, "Error at %v|%v", v.path1, v.path2)
}
}
func TestCmp(t *testing.T) {
for _, v := range []struct {
expected bool
path1 string
path2 string
}{
{true, "./test_data/a.txt", "./test_data/b.txt"},
{false, "./test_data/a.txt", "./test_data/c.txt"},
{false, "./test_data/a.txt", "./test_data/d.txt"},
{false, "./test_data/c.txt", "./test_data/d.txt"},
{true, "./test_data/data1", "./test_data/data2"},
{false, "./test_data/data1", "./test_data/data3"},
{false, "./test_data/data1", "./test_data/data4"},
} {
ok, _, err := Cmp(v.path1, v.path2)
assert.NoError(t, err)
assert.Equal(t, v.expected, ok, "Error at %v|%v", v.path1, v.path2)
}
}