-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathfixture_test.go
69 lines (62 loc) · 1.25 KB
/
fixture_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
60
61
62
63
64
65
66
67
68
69
package fixture
import (
"testing"
"time"
"github.com/pkg/errors"
"github.com/stretchr/testify/assert"
)
func TestExec(t *testing.T) {
now := time.Now()
cases := []struct {
input QueryModelWithYaml
expect error
}{
{
QueryModelWithYaml{
Table: "test",
ColumnFamilies: []ColumnFamilies{
{
Family: "d",
Columns: []Columns{
{
Key: "1",
Rows: map[string]interface{}{
"name": "foo",
"age": "1",
},
Version: Version{now},
},
},
},
},
},
nil,
},
}
for _, c := range cases {
f, err := New("test-project", "test-instance")
assert.NoError(t, err)
err = f.clearTable(c.input.Table)
assert.NoError(t, err)
err = f.exec(c.input)
assert.Equal(t, c.expect, errors.Cause(err))
}
}
func TestLoad(t *testing.T) {
cases := []struct {
input string
expect error
}{
{"testdata/test.yml", nil},
{"testdata/version.yaml", nil},
{"testdata/invalid.ext", ErrUnknownFileExt},
{"testdata/invalid.yaml", ErrInvalidFixture},
{"not_exists.yml", ErrFailReadFile},
}
for _, c := range cases {
f, err := New("test-project", "test-instance")
assert.NoError(t, err)
err = f.Load(c.input)
assert.Equal(t, c.expect, errors.Cause(err))
}
}