@@ -113,6 +113,49 @@ var testCasesData = []testCases{
113
113
result : false ,
114
114
jsonText : jsonStatefulset ,
115
115
},
116
+ /* The json expression that can be provided as a condition in the check hook spec follows the format
117
+
118
+ <expression1> op <expression2>
119
+ With some of the conditions below:
120
+
121
+ 1. Both the expressions should individually comply to be a valid json expression.
122
+ 2. An expression should be enclosed with curly braces {}.
123
+ 3. An expression could either be a json expression that can be evaluated from the pod/deployment/statefulset json
124
+ content or a literal which can be either string or number.
125
+ Some improvements needs to be done which are added as sub-issues linked to this one.
126
+
127
+ Adding the commented TCs which are to pass when the improvements are done.
128
+ */
129
+ // {
130
+ // jsonPathExprs: "{$.status.conditions[0].status} == {True}",
131
+ // result: true,
132
+ // jsonText: jsonStatefulset,
133
+ // },
134
+ // {
135
+ // jsonPathExprs: "{$.spec.replicas} == {1}",
136
+ // result: true,
137
+ // jsonText: jsonPod,
138
+ // },
139
+ // {
140
+ // jsonPathExprs: "{$.status.conditions[0].status} == {\"True\"}",
141
+ // result: true,
142
+ // jsonText: jsonStatefulset,
143
+ // },
144
+ // {
145
+ // jsonPathExprs: "{$.status.conditions[?(@type.==\"Progressing\")].status} == {True}",
146
+ // result: true,
147
+ // jsonText: jsonPod,
148
+ // },
149
+ // {
150
+ // jsonPathExprs: "{$.spec.replicas} == {1} || $.status.conditions[0].status == {True}",
151
+ // result: true,
152
+ // jsonText: jsonPod,
153
+ // },
154
+ // {
155
+ // jsonPathExprs: "{$.spec.replicas} == {1} && $.status.conditions[0].status == {True}",
156
+ // result: true,
157
+ // jsonText: jsonPod,
158
+ // },
116
159
}
117
160
118
161
var testCasesObjectData = []testCasesObject {
@@ -200,6 +243,28 @@ func Test_isValidJsonPathExpression(t *testing.T) {
200
243
args args
201
244
want bool
202
245
}{
246
+ /* Same comments as above */
247
+ // {
248
+ // name: "String expression",
249
+ // args: args{
250
+ // expr: "{True}",
251
+ // },
252
+ // want: true,
253
+ // },
254
+ // {
255
+ // name: "String expression 1",
256
+ // args: args{
257
+ // expr: "{\"Ready\"}",
258
+ // },
259
+ // want: true,
260
+ // },
261
+ // {
262
+ // name: "Number expression",
263
+ // args: args{
264
+ // expr: "{10}",
265
+ // },
266
+ // want: true,
267
+ // },
203
268
{
204
269
name : "Simple expression" ,
205
270
args : args {
0 commit comments