-
Notifications
You must be signed in to change notification settings - Fork 133
Expand file tree
/
Copy pathapply_test.go
More file actions
67 lines (59 loc) · 1.9 KB
/
apply_test.go
File metadata and controls
67 lines (59 loc) · 1.9 KB
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
//go:build integration
package integration
import (
"testing"
"github.com/stretchr/testify/assert"
)
func Test_Apply_3x(t *testing.T) {
// setup stage
tests := []struct {
name string
firstFile string
secondFile string
expectedState string
runWhen string
}{
{
name: "applies multiple of the same entity",
firstFile: "testdata/apply/001-same-type/service-01.yaml",
secondFile: "testdata/apply/001-same-type/service-02.yaml",
expectedState: "testdata/apply/001-same-type/expected-state.yaml",
runWhen: "kong",
},
{
name: "applies different entity types",
firstFile: "testdata/apply/002-different-types/service-01.yaml",
secondFile: "testdata/apply/002-different-types/plugin-01.yaml",
expectedState: "testdata/apply/002-different-types/expected-state.yaml",
runWhen: "kong",
},
{
name: "accepts consumer foreign keys",
firstFile: "testdata/apply/003-foreign-keys-consumers/consumer-01.yaml",
secondFile: "testdata/apply/003-foreign-keys-consumers/plugin-01.yaml",
expectedState: "testdata/apply/003-foreign-keys-consumers/expected-state.yaml",
runWhen: "kong",
},
{
name: "accepts consumer group foreign keys",
firstFile: "testdata/apply/004-foreign-keys-consumer-groups/consumer-group-01.yaml",
secondFile: "testdata/apply/004-foreign-keys-consumer-groups/consumer-01.yaml",
expectedState: "testdata/apply/004-foreign-keys-consumer-groups/expected-state.yaml",
runWhen: "enterprise",
},
}
for _, tc := range tests {
t.Run(tc.name, func(t *testing.T) {
runWhen(t, tc.runWhen, ">=3.0.0")
setup(t)
apply(tc.firstFile)
apply(tc.secondFile)
out, _ := dump()
expected, err := readFile(tc.expectedState)
if err != nil {
t.Fatalf("failed to read expected state: %v", err)
}
assert.Equal(t, expected, out)
})
}
}