@@ -42,10 +42,8 @@ func TestConditionTreeEvaluateSimpleCondition(t *testing.T) {
42
42
43
43
// Test match
44
44
user := e.UserContext {
45
- Attributes : e.UserAttributes {
46
- Attributes : map [string ]interface {}{
47
- "string_foo" : "foo" ,
48
- },
45
+ Attributes : map [string ]interface {}{
46
+ "string_foo" : "foo" ,
49
47
},
50
48
}
51
49
condTreeParams := e .NewTreeParameters (& user , map [string ]e.Audience {})
@@ -54,10 +52,8 @@ func TestConditionTreeEvaluateSimpleCondition(t *testing.T) {
54
52
55
53
// Test no match
56
54
user = e.UserContext {
57
- Attributes : e.UserAttributes {
58
- Attributes : map [string ]interface {}{
59
- "string_foo" : "not foo" ,
60
- },
55
+ Attributes : map [string ]interface {}{
56
+ "string_foo" : "not foo" ,
61
57
},
62
58
}
63
59
result = conditionTreeEvaluator .Evaluate (conditionTree , condTreeParams )
@@ -80,10 +76,8 @@ func TestConditionTreeEvaluateMultipleOrConditions(t *testing.T) {
80
76
81
77
// Test match string
82
78
user := e.UserContext {
83
- Attributes : e.UserAttributes {
84
- Attributes : map [string ]interface {}{
85
- "string_foo" : "foo" ,
86
- },
79
+ Attributes : map [string ]interface {}{
80
+ "string_foo" : "foo" ,
87
81
},
88
82
}
89
83
@@ -93,34 +87,28 @@ func TestConditionTreeEvaluateMultipleOrConditions(t *testing.T) {
93
87
94
88
// Test match bool
95
89
user = e.UserContext {
96
- Attributes : e.UserAttributes {
97
- Attributes : map [string ]interface {}{
98
- "bool_true" : true ,
99
- },
90
+ Attributes : map [string ]interface {}{
91
+ "bool_true" : true ,
100
92
},
101
93
}
102
94
result = conditionTreeEvaluator .Evaluate (conditionTree , condTreeParams )
103
95
assert .True (t , result )
104
96
105
97
// Test match both
106
98
user = e.UserContext {
107
- Attributes : e.UserAttributes {
108
- Attributes : map [string ]interface {}{
109
- "string_foo" : "foo" ,
110
- "bool_true" : true ,
111
- },
99
+ Attributes : map [string ]interface {}{
100
+ "string_foo" : "foo" ,
101
+ "bool_true" : true ,
112
102
},
113
103
}
114
104
result = conditionTreeEvaluator .Evaluate (conditionTree , condTreeParams )
115
105
assert .True (t , result )
116
106
117
107
// Test no match
118
108
user = e.UserContext {
119
- Attributes : e.UserAttributes {
120
- Attributes : map [string ]interface {}{
121
- "string_foo" : "not foo" ,
122
- "bool_true" : false ,
123
- },
109
+ Attributes : map [string ]interface {}{
110
+ "string_foo" : "not foo" ,
111
+ "bool_true" : false ,
124
112
},
125
113
}
126
114
result = conditionTreeEvaluator .Evaluate (conditionTree , condTreeParams )
@@ -143,10 +131,8 @@ func TestConditionTreeEvaluateMultipleAndConditions(t *testing.T) {
143
131
144
132
// Test only string match with NULL bubbling
145
133
user := e.UserContext {
146
- Attributes : e.UserAttributes {
147
- Attributes : map [string ]interface {}{
148
- "string_foo" : "foo" ,
149
- },
134
+ Attributes : map [string ]interface {}{
135
+ "string_foo" : "foo" ,
150
136
},
151
137
}
152
138
@@ -156,34 +142,28 @@ func TestConditionTreeEvaluateMultipleAndConditions(t *testing.T) {
156
142
157
143
// Test only bool match with NULL bubbling
158
144
user = e.UserContext {
159
- Attributes : e.UserAttributes {
160
- Attributes : map [string ]interface {}{
161
- "bool_true" : true ,
162
- },
145
+ Attributes : map [string ]interface {}{
146
+ "bool_true" : true ,
163
147
},
164
148
}
165
149
result = conditionTreeEvaluator .Evaluate (conditionTree , condTreeParams )
166
150
assert .False (t , result )
167
151
168
152
// Test match both
169
153
user = e.UserContext {
170
- Attributes : e.UserAttributes {
171
- Attributes : map [string ]interface {}{
172
- "string_foo" : "foo" ,
173
- "bool_true" : true ,
174
- },
154
+ Attributes : map [string ]interface {}{
155
+ "string_foo" : "foo" ,
156
+ "bool_true" : true ,
175
157
},
176
158
}
177
159
result = conditionTreeEvaluator .Evaluate (conditionTree , condTreeParams )
178
160
assert .True (t , result )
179
161
180
162
// Test no match
181
163
user = e.UserContext {
182
- Attributes : e.UserAttributes {
183
- Attributes : map [string ]interface {}{
184
- "string_foo" : "not foo" ,
185
- "bool_true" : false ,
186
- },
164
+ Attributes : map [string ]interface {}{
165
+ "string_foo" : "not foo" ,
166
+ "bool_true" : false ,
187
167
},
188
168
}
189
169
result = conditionTreeEvaluator .Evaluate (conditionTree , condTreeParams )
@@ -217,10 +197,8 @@ func TestConditionTreeEvaluateNotCondition(t *testing.T) {
217
197
218
198
// Test match string
219
199
user := e.UserContext {
220
- Attributes : e.UserAttributes {
221
- Attributes : map [string ]interface {}{
222
- "string_foo" : "not foo" ,
223
- },
200
+ Attributes : map [string ]interface {}{
201
+ "string_foo" : "not foo" ,
224
202
},
225
203
}
226
204
@@ -230,34 +208,28 @@ func TestConditionTreeEvaluateNotCondition(t *testing.T) {
230
208
231
209
// Test match bool
232
210
user = e.UserContext {
233
- Attributes : e.UserAttributes {
234
- Attributes : map [string ]interface {}{
235
- "bool_true" : false ,
236
- },
211
+ Attributes : map [string ]interface {}{
212
+ "bool_true" : false ,
237
213
},
238
214
}
239
215
result = conditionTreeEvaluator .Evaluate (conditionTree , condTreeParams )
240
216
assert .True (t , result )
241
217
242
218
// Test match both
243
219
user = e.UserContext {
244
- Attributes : e.UserAttributes {
245
- Attributes : map [string ]interface {}{
246
- "string_foo" : "not foo" ,
247
- "bool_true" : false ,
248
- },
220
+ Attributes : map [string ]interface {}{
221
+ "string_foo" : "not foo" ,
222
+ "bool_true" : false ,
249
223
},
250
224
}
251
225
result = conditionTreeEvaluator .Evaluate (conditionTree , condTreeParams )
252
226
assert .True (t , result )
253
227
254
228
// Test no match
255
229
user = e.UserContext {
256
- Attributes : e.UserAttributes {
257
- Attributes : map [string ]interface {}{
258
- "string_foo" : "foo" ,
259
- "bool_true" : true ,
260
- },
230
+ Attributes : map [string ]interface {}{
231
+ "string_foo" : "foo" ,
232
+ "bool_true" : true ,
261
233
},
262
234
}
263
235
result = conditionTreeEvaluator .Evaluate (conditionTree , condTreeParams )
@@ -302,12 +274,10 @@ func TestConditionTreeEvaluateMultipleMixedConditions(t *testing.T) {
302
274
303
275
// Test only match AND condition
304
276
user := e.UserContext {
305
- Attributes : e.UserAttributes {
306
- Attributes : map [string ]interface {}{
307
- "string_foo" : "foo" ,
308
- "bool_true" : true ,
309
- "int_42" : 43 ,
310
- },
277
+ Attributes : map [string ]interface {}{
278
+ "string_foo" : "foo" ,
279
+ "bool_true" : true ,
280
+ "int_42" : 43 ,
311
281
},
312
282
}
313
283
@@ -317,38 +287,32 @@ func TestConditionTreeEvaluateMultipleMixedConditions(t *testing.T) {
317
287
318
288
// Test only match the NOT condition
319
289
user = e.UserContext {
320
- Attributes : e.UserAttributes {
321
- Attributes : map [string ]interface {}{
322
- "string_foo" : "not foo" ,
323
- "bool_true" : true ,
324
- "int_42" : 43 ,
325
- },
290
+ Attributes : map [string ]interface {}{
291
+ "string_foo" : "not foo" ,
292
+ "bool_true" : true ,
293
+ "int_42" : 43 ,
326
294
},
327
295
}
328
296
result = conditionTreeEvaluator .Evaluate (conditionTree , condTreeParams )
329
297
assert .True (t , result )
330
298
331
299
// Test only match the int condition
332
300
user = e.UserContext {
333
- Attributes : e.UserAttributes {
334
- Attributes : map [string ]interface {}{
335
- "string_foo" : "foo" ,
336
- "bool_true" : false ,
337
- "int_42" : 42 ,
338
- },
301
+ Attributes : map [string ]interface {}{
302
+ "string_foo" : "foo" ,
303
+ "bool_true" : false ,
304
+ "int_42" : 42 ,
339
305
},
340
306
}
341
307
result = conditionTreeEvaluator .Evaluate (conditionTree , condTreeParams )
342
308
assert .True (t , result )
343
309
344
310
// Test no match
345
311
user = e.UserContext {
346
- Attributes : e.UserAttributes {
347
- Attributes : map [string ]interface {}{
348
- "string_foo" : "foo" ,
349
- "bool_true" : false ,
350
- "int_42" : 43 ,
351
- },
312
+ Attributes : map [string ]interface {}{
313
+ "string_foo" : "foo" ,
314
+ "bool_true" : false ,
315
+ "int_42" : 43 ,
352
316
},
353
317
}
354
318
result = conditionTreeEvaluator .Evaluate (conditionTree , condTreeParams )
0 commit comments