-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathconf_test.go
92 lines (88 loc) · 1.56 KB
/
conf_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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
package eskeeper
import (
"os"
"reflect"
"testing"
)
func TestYaml2Conf(t *testing.T) {
tests := []struct {
name string
yaml string
want config
}{
{
name: "simple",
yaml: "testdata/es.yaml",
want: config{
Indices: []index{
{
Name: "test-v1",
Mapping: "testdata/test.json",
},
{
Name: "test-v2",
Mapping: "testdata/test.json",
},
{
Name: "close-v1",
Mapping: "testdata/test.json",
Status: "close",
},
},
Aliases: []alias{
{
Name: "alias1",
Indices: []string{"test-v1"},
},
{
Name: "alias2",
Indices: []string{"test-v1", "test-v2"},
},
},
},
},
{
name: "reindex",
yaml: "testdata/es.reindex.yaml",
want: config{
Indices: []index{
{
Name: "test-v1",
Mapping: "testdata/test.json",
},
{
Name: "reindex-v1",
Mapping: "testdata/test.json",
Reindex: reindex{
Source: "test-v1",
Slices: 3,
WaitForCompletion: true,
On: "firstCreated",
},
},
},
Aliases: []alias{
{
Name: "alias1",
Indices: []string{"test-v2"},
},
},
},
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
r, err := os.Open(tt.yaml)
if err != nil {
t.Fatal(err)
}
got, err := yaml2Conf(r)
if err != nil {
t.Fatal(err)
}
if !reflect.DeepEqual(got, tt.want) {
t.Errorf("\nwant: %+v\ngot : %+v\n", tt.want, got)
}
})
}
}