Skip to content
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
3 changes: 3 additions & 0 deletions evaluation/target.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ func (t Target) GetAttrValue(attr string) reflect.Value {

// GetOperator returns interface based on attribute value
func (t Target) GetOperator(attr string) (types.ValueType, error) {
if attr == "" {
return nil, nil
}
value := t.GetAttrValue(attr)
switch value.Kind() {
case reflect.Bool:
Expand Down
7 changes: 7 additions & 0 deletions evaluation/target_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,13 @@ func TestTarget_GetOperator(t1 *testing.T) {
"weight": 99.99,
}},
args: struct{ attr string }{attr: "weight"}, want: types.Number(99.99)},
{name: "empty operator", fields: struct {
Identifier string
Name *string
Anonymous bool
Attributes map[string]interface{}
}{Identifier: "harness", Name: nil, Anonymous: false, Attributes: map[string]interface{}{}},
args: struct{ attr string }{attr: ""}, want: nil},
}
for _, tt := range tests {
val := tt
Expand Down