@@ -14,13 +14,13 @@ func Test_Validation(t *testing.T) {
14
14
Conditions : []ConditionWithParams {
15
15
{
16
16
Type : AlertIsFiring ,
17
- Params : AlertIsFiringConditionParams {
17
+ Alert : & AlertConditionParams {
18
18
Name : "test1" ,
19
19
},
20
20
},
21
21
{
22
22
Type : AlertIsFiring ,
23
- Params : AlertIsFiringConditionParams {
23
+ Alert : & AlertConditionParams {
24
24
Name : "test2" ,
25
25
},
26
26
},
@@ -53,7 +53,7 @@ func Test_Validation_InvalidGatheringRules(t *testing.T) {
53
53
Conditions : []ConditionWithParams {
54
54
{
55
55
Type : AlertIsFiring ,
56
- Params : AlertIsFiringConditionParams {
56
+ Alert : & AlertConditionParams {
57
57
Name : "test" + fmt .Sprint (i ),
58
58
},
59
59
},
@@ -81,7 +81,7 @@ func Test_Validation_InvalidGatheringRules(t *testing.T) {
81
81
Conditions : []ConditionWithParams {
82
82
{
83
83
Type : AlertIsFiring ,
84
- Params : AlertIsFiringConditionParams {
84
+ Alert : & AlertConditionParams {
85
85
Name : "test1" ,
86
86
},
87
87
},
@@ -96,7 +96,7 @@ func Test_Validation_InvalidGatheringRules(t *testing.T) {
96
96
Conditions : []ConditionWithParams {
97
97
{
98
98
Type : AlertIsFiring ,
99
- Params : AlertIsFiringConditionParams {
99
+ Alert : & AlertConditionParams {
100
100
Name : "test1" ,
101
101
},
102
102
},
@@ -140,11 +140,11 @@ func Test_Validation_InvalidConditions(t *testing.T) {
140
140
}},
141
141
Errors : []string {
142
142
`0.conditions.0: Must validate at least one schema (anyOf)` ,
143
+ `0.conditions.0: alert is required` ,
143
144
`0.conditions.0.type: 0.conditions.0.type does not match: "alert_is_firing"` ,
144
- `0.conditions.0.params: Invalid type. Expected: object, given: null` ,
145
145
`0.conditions.1: Must validate at least one schema (anyOf)` ,
146
+ `0.conditions.1: alert is required` ,
146
147
`0.conditions.1.type: 0.conditions.1.type does not match: "alert_is_firing"` ,
147
- `0.conditions.1.params: Invalid type. Expected: object, given: null` ,
148
148
`0.gathering_functions: Invalid type. Expected: object, given: null` ,
149
149
},
150
150
},
@@ -153,14 +153,14 @@ func Test_Validation_InvalidConditions(t *testing.T) {
153
153
Rules : []GatheringRule {{
154
154
Conditions : []ConditionWithParams {
155
155
{
156
- Type : AlertIsFiring ,
157
- Params : "using incorrect type for params" ,
156
+ Type : AlertIsFiring ,
157
+ Alert : nil ,
158
158
},
159
159
},
160
160
}},
161
161
Errors : []string {
162
162
`0.conditions.0: Must validate at least one schema (anyOf)` ,
163
- `0.conditions.0.params: Invalid type. Expected: object, given: string ` ,
163
+ `0.conditions.0: alert is required ` ,
164
164
`0.gathering_functions: Invalid type. Expected: object, given: null` ,
165
165
},
166
166
},
@@ -170,15 +170,15 @@ func Test_Validation_InvalidConditions(t *testing.T) {
170
170
Conditions : []ConditionWithParams {
171
171
{
172
172
Type : AlertIsFiring ,
173
- Params : AlertIsFiringConditionParams {
173
+ Alert : & AlertConditionParams {
174
174
Name : "contains invalid characters $^#!@$%&" ,
175
175
},
176
176
},
177
177
},
178
178
}},
179
179
Errors : []string {
180
180
`0.conditions.0: Must validate at least one schema (anyOf)` ,
181
- `0.conditions.0.params .name: Does not match pattern '^[a-zA-Z0-9_]{1,128}$'` ,
181
+ `0.conditions.0.alert .name: Does not match pattern '^[a-zA-Z0-9_]{1,128}$'` ,
182
182
`0.gathering_functions: Invalid type. Expected: object, given: null` ,
183
183
},
184
184
},
@@ -188,7 +188,7 @@ func Test_Validation_InvalidConditions(t *testing.T) {
188
188
Conditions : []ConditionWithParams {
189
189
{
190
190
Type : AlertIsFiring ,
191
- Params : AlertIsFiringConditionParams {
191
+ Alert : & AlertConditionParams {
192
192
Name : "" , // empty
193
193
},
194
194
},
@@ -197,7 +197,7 @@ func Test_Validation_InvalidConditions(t *testing.T) {
197
197
Errors : []string {
198
198
`0.gathering_functions: Invalid type. Expected: object, given: null` ,
199
199
`0.conditions.0: Must validate at least one schema (anyOf)` ,
200
- `0.conditions.0.params .name: Does not match pattern '^[a-zA-Z0-9_]{1,128}$'` ,
200
+ `0.conditions.0.alert .name: Does not match pattern '^[a-zA-Z0-9_]{1,128}$'` ,
201
201
},
202
202
},
203
203
{
@@ -206,15 +206,15 @@ func Test_Validation_InvalidConditions(t *testing.T) {
206
206
Conditions : []ConditionWithParams {
207
207
{
208
208
Type : AlertIsFiring ,
209
- Params : AlertIsFiringConditionParams {
209
+ Alert : & AlertConditionParams {
210
210
Name : rand .String (1024 ), // too long
211
211
},
212
212
},
213
213
},
214
214
}},
215
215
Errors : []string {
216
216
`0.conditions.0: Must validate at least one schema (anyOf)` ,
217
- `0.conditions.0.params .name: Does not match pattern '^[a-zA-Z0-9_]{1,128}$'` ,
217
+ `0.conditions.0.alert .name: Does not match pattern '^[a-zA-Z0-9_]{1,128}$'` ,
218
218
`0.gathering_functions: Invalid type. Expected: object, given: null` ,
219
219
},
220
220
},
0 commit comments