Commit 2dcab522
2dcab522c46aMerged
Sviatoslav Dumchenko <[email protected]> ยท 3 years ago ยท 1 file ยท ~1 modified
Description
chore(tests): add some template tests
Details
- Commit
- 2dcab522c46a
- Parent
- 3e6ef66fdb1a
pkg/template/extra_test.gomodifiedView file
@@ -88,7 +88,7 @@
8888
}8989
9090
func (s *ExtraTestSuite) TestExecError() {91-
res, err := template.Exec(s.T().Name(), []any{})91+
res, err := template.Exec("pwd", []any{"test"})9292
s.Require().Error(err)9393
s.Require().Empty(res)9494
}@@ -106,6 +106,9 @@
106106
"b": "123",107107
},108108
"c": 123,109+
"d": map[any]any{110+
"e": "f",111+
},109112
}110113
111114
tests := []struct {@@ -120,6 +123,9 @@
120123
result: template.Values{121124
"a": map[string]any{"b": "123"},122125
"c": 321,126+
"d": map[any]any{127+
"e": "f",128+
},123129
},124130
fails: false,125131
},@@ -129,6 +135,9 @@
129135
result: template.Values{130136
"a": map[string]any{"b": "321"},131137
"c": 321,138+
"d": map[any]any{139+
"e": "f",140+
},132141
},133142
fails: false,134143
},@@ -138,6 +147,9 @@
138147
result: template.Values{139148
"a": map[string]any{"b": "321", "c": "321"},140149
"c": 321,150+
"d": map[any]any{151+
"e": "f",152+
},141153
},142154
fails: false,143155
},@@ -147,6 +159,18 @@
147159
result: nil,148160
fails: true,149161
},162+
{163+
path: "d.e",164+
value: "321",165+
result: template.Values{166+
"a": map[string]any{"b": "321", "c": "321"},167+
"c": 321,168+
"d": map[any]any{169+
"e": "321",170+
},171+
},172+
fails: false,173+
},150174
}151175
152176
for i := range tests {@@ -222,6 +246,9 @@
222246
"b": "123",223247
},224248
"c": 123,249+
"d": map[any]any{250+
"e": "f",251+
},225252
}226253
227254
tests := []struct {@@ -249,6 +276,11 @@
249276
result: nil,250277
fails: true,251278
},279+
{280+
path: "d.e",281+
result: "f",282+
fails: false,283+
},252284
}253285
254286
for i := range tests {@@ -269,6 +301,9 @@
269301
"b": "123",270302
},271303
"c": 123,304+
"d": map[any]any{305+
"e": "f",306+
},272307
}273308
274309
tests := []struct {@@ -296,6 +331,11 @@
296331
result: false,297332
fails: true,298333
},334+
{335+
path: "d.e",336+
result: true,337+
fails: false,338+
},299339
}300340
301341
for _, test := range tests {