Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(flags): Don't match unknown operators #24

Merged
merged 1 commit into from
Jan 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading