Skip to content

Commit

Permalink
fix(flags): Don't match unknown operators (#24)
Browse files Browse the repository at this point in the history
  • Loading branch information
neilkakkar authored Jan 10, 2024
1 parent d607812 commit f2ee529
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
22 changes: 22 additions & 0 deletions feature_flags_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,28 @@ func TestMatchPropertyValue(t *testing.T) {
}

}


func TestMatchPropertyInvalidOperator(t *testing.T) {
property := Property{
Key: "Browser",
Value: "Chrome",
Operator: "is_unknown",
}

properties := NewProperties().Set("Browser", "Chrome")

isMatch, err := matchProperty(property, properties)

if isMatch == true {
t.Error("Should not match")
}

if _, ok := err.(*InconclusiveMatchError); !ok {
t.Error("Error type is not a match")
}

}
func TestMatchPropertySlice(t *testing.T) {

property := Property{
Expand Down
3 changes: 2 additions & 1 deletion featureflags.go
Original file line number Diff line number Diff line change
Expand Up @@ -531,7 +531,8 @@ func matchProperty(property Property, properties Properties) (bool, error) {
return overrideValueOrderable <= valueOrderable, nil
}

return false, nil
return false, &InconclusiveMatchError{"Unknown operator: " + operator}

}

func validateOrderable(firstValue interface{}, secondValue interface{}) (float64, float64, error) {
Expand Down

0 comments on commit f2ee529

Please sign in to comment.