@@ -6,13 +6,13 @@ import (
6
6
"github.com/stretchr/testify/assert"
7
7
)
8
8
9
- var greaterThanCondition = condition {operator : "GT" , value : 10.0 , attribute : "age" }
10
- var lessThanCondition = condition {operator : "LT" , value : 100.0 , attribute : "age" }
11
- var numericRule = rule {conditions : []condition {greaterThanCondition , lessThanCondition }}
9
+ var greaterThanCondition = condition {Operator : "GT" , Value : 10.0 , Attribute : "age" }
10
+ var lessThanCondition = condition {Operator : "LT" , Value : 100.0 , Attribute : "age" }
11
+ var numericRule = rule {Conditions : []condition {greaterThanCondition , lessThanCondition }}
12
12
13
- var matchesEmailCondition = condition {operator : "MATCHES" , value : ".*@email.com" , attribute : "email" }
14
- var textRule = rule {conditions : []condition {matchesEmailCondition }}
15
- var ruleWithEmptyConditions = rule {conditions : []condition {}}
13
+ var matchesEmailCondition = condition {Operator : "MATCHES" , Value : ".*@email.com" , Attribute : "email" }
14
+ var textRule = rule {Conditions : []condition {matchesEmailCondition }}
15
+ var ruleWithEmptyConditions = rule {Conditions : []condition {}}
16
16
17
17
func Test_matchesAnyRule_withEmptyRules (t * testing.T ) {
18
18
expected := false
@@ -84,8 +84,8 @@ func Test_matchesAnyRule_NumericOperatorWithString(t *testing.T) {
84
84
func Test_matchesAnyRule_NumericValueAndRegex (t * testing.T ) {
85
85
expected := true
86
86
87
- cdn := condition {operator : "MATCHES" , value : "[0-9]+" , attribute : "age" }
88
- rl := rule {conditions : []condition {cdn }}
87
+ cdn := condition {Operator : "MATCHES" , Value : "[0-9]+" , Attribute : "age" }
88
+ rl := rule {Conditions : []condition {cdn }}
89
89
90
90
subjectAttributes := make (dictionary )
91
91
subjectAttributes ["age" ] = 99
@@ -102,8 +102,8 @@ type MatchesAnyRuleTest []struct {
102
102
}
103
103
104
104
func Test_matchesAnyRule_oneOfOperatorWithBoolean (t * testing.T ) {
105
- oneOfRule := rule {conditions : []condition {{operator : "ONE_OF" , value : []string {"true" }, attribute : "enabled" }}}
106
- notOneOfRule := rule {conditions : []condition {{operator : "NOT_ONE_OF" , value : []string {"True" }, attribute : "enabled" }}}
105
+ oneOfRule := rule {Conditions : []condition {{Operator : "ONE_OF" , Value : []string {"true" }, Attribute : "enabled" }}}
106
+ notOneOfRule := rule {Conditions : []condition {{Operator : "NOT_ONE_OF" , Value : []string {"True" }, Attribute : "enabled" }}}
107
107
108
108
subjectAttributesEnabled := make (dictionary )
109
109
subjectAttributesEnabled ["enabled" ] = "true"
@@ -126,7 +126,7 @@ func Test_matchesAnyRule_oneOfOperatorWithBoolean(t *testing.T) {
126
126
}
127
127
128
128
func Test_matchesAnyRule_OneOfOperatorCaseInsensitive (t * testing.T ) {
129
- oneOfRule := rule {conditions : []condition {{operator : "ONE_OF" , value : []string {"1Ab" , "Ron" }, attribute : "name" }}}
129
+ oneOfRule := rule {Conditions : []condition {{Operator : "ONE_OF" , Value : []string {"1Ab" , "Ron" }, Attribute : "name" }}}
130
130
subjectAttributes0 := make (dictionary )
131
131
subjectAttributes0 ["name" ] = "ron"
132
132
@@ -146,7 +146,7 @@ func Test_matchesAnyRule_OneOfOperatorCaseInsensitive(t *testing.T) {
146
146
}
147
147
148
148
func Test_matchesAnyRule_NotOneOfOperatorCaseInsensitive (t * testing.T ) {
149
- notOneOfRule := rule {conditions : []condition {{operator : "NOT_ONE_OF" , value : []string {"bbB" , "1.1.ab" }, attribute : "name" }}}
149
+ notOneOfRule := rule {Conditions : []condition {{Operator : "NOT_ONE_OF" , Value : []string {"bbB" , "1.1.ab" }, Attribute : "name" }}}
150
150
subjectAttributes0 := make (dictionary )
151
151
subjectAttributes0 ["name" ] = "BBB"
152
152
@@ -166,8 +166,8 @@ func Test_matchesAnyRule_NotOneOfOperatorCaseInsensitive(t *testing.T) {
166
166
}
167
167
168
168
func Test_matchesAnyRule_OneOfOperatorWithString (t * testing.T ) {
169
- oneOfRule := rule {conditions : []condition {{operator : "ONE_OF" , value : []string {"john" , "ron" }, attribute : "name" }}}
170
- notOneOfRule := rule {conditions : []condition {{operator : "NOT_ONE_OF" , value : []string {"ron" }, attribute : "name" }}}
169
+ oneOfRule := rule {Conditions : []condition {{Operator : "ONE_OF" , Value : []string {"john" , "ron" }, Attribute : "name" }}}
170
+ notOneOfRule := rule {Conditions : []condition {{Operator : "NOT_ONE_OF" , Value : []string {"ron" }, Attribute : "name" }}}
171
171
172
172
subjectAttributesJohn := make (dictionary )
173
173
subjectAttributesJohn ["name" ] = "john"
@@ -194,8 +194,8 @@ func Test_matchesAnyRule_OneOfOperatorWithString(t *testing.T) {
194
194
}
195
195
196
196
func Test_matchesAnyRule_OneOfOperatorWithNumber (t * testing.T ) {
197
- oneOfRule := rule {conditions : []condition {{operator : "ONE_OF" , value : []string {"14" , "15.11" , "15" }, attribute : "number" }}}
198
- notOneOfRule := rule {conditions : []condition {{operator : "NOT_ONE_OF" , value : []string {"10" }, attribute : "number" }}}
197
+ oneOfRule := rule {Conditions : []condition {{Operator : "ONE_OF" , Value : []string {"14" , "15.11" , "15" }, Attribute : "number" }}}
198
+ notOneOfRule := rule {Conditions : []condition {{Operator : "NOT_ONE_OF" , Value : []string {"10" }, Attribute : "number" }}}
199
199
200
200
subjectAttributes0 := make (dictionary )
201
201
subjectAttributes0 ["number" ] = "14"
@@ -272,18 +272,18 @@ func Test_isNotOneOf_Fail(t *testing.T) {
272
272
273
273
func Test_evaluateNumericCondition_Success (t * testing.T ) {
274
274
expected := false
275
- result := evaluateNumericCondition (40 , condition {operator : "LT" , value : 30.0 })
275
+ result := evaluateNumericCondition (40 , condition {Operator : "LT" , Value : 30.0 })
276
276
277
277
assert .Equal (t , expected , result )
278
278
}
279
279
280
280
func Test_evaluateNumericCondition_Fail (t * testing.T ) {
281
281
expected := true
282
- result := evaluateNumericCondition (25 , condition {operator : "LT" , value : 30.0 })
282
+ result := evaluateNumericCondition (25 , condition {Operator : "LT" , Value : 30.0 })
283
283
284
284
assert .Equal (t , expected , result )
285
285
}
286
286
287
287
func Test_evaluateNumericCondition_IncorrectOperator (t * testing.T ) {
288
- assert .Panics (t , func () { evaluateNumericCondition (25 , condition {operator : "LTGT" , value : 30.0 }) })
288
+ assert .Panics (t , func () { evaluateNumericCondition (25 , condition {Operator : "LTGT" , Value : 30.0 }) })
289
289
}
0 commit comments