Skip to content

Commit 1e30183

Browse files
YuanCMichael Ng
authored andcommitted
fix substring matcher reversal (#64)
1 parent 485e246 commit 1e30183

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

optimizely/decision/evaluator/matchers/substring.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ func (m SubstringMatcher) Match(user entities.UserContext) (bool, error) {
3636
if err != nil {
3737
return false, err
3838
}
39-
return strings.Contains(stringValue, attributeValue), nil
39+
return strings.Contains(attributeValue, stringValue), nil
4040
}
4141

4242
return false, fmt.Errorf("audience condition %s evaluated to NULL because the condition value type is not supported", m.Condition.Name)

optimizely/decision/evaluator/matchers/substring_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,15 +28,15 @@ func TestSubstringMatcher(t *testing.T) {
2828
matcher := SubstringMatcher{
2929
Condition: entities.Condition{
3030
Match: "substring",
31-
Value: "foobar",
31+
Value: "foo",
3232
Name: "string_foo",
3333
},
3434
}
3535

3636
// Test match
3737
user := entities.UserContext{
3838
Attributes: map[string]interface{}{
39-
"string_foo": "foo",
39+
"string_foo": "foobar",
4040
},
4141
}
4242

@@ -47,7 +47,7 @@ func TestSubstringMatcher(t *testing.T) {
4747
// Test no match
4848
user = entities.UserContext{
4949
Attributes: map[string]interface{}{
50-
"string_foo": "not_foobar",
50+
"string_foo": "bar",
5151
},
5252
}
5353

0 commit comments

Comments
 (0)