Skip to content

Commit 240220d

Browse files
author
Andrew Hayes
authored
Merge pull request #38 from drone/FFM-1290_group_match_warn_log
(FFM-1290) Ignored empty evaliation attibute
2 parents 85fd7e0 + d0b38a4 commit 240220d

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

evaluation/target.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,9 @@ func (t Target) GetAttrValue(attr string) reflect.Value {
3131

3232
// GetOperator returns interface based on attribute value
3333
func (t Target) GetOperator(attr string) (types.ValueType, error) {
34+
if attr == "" {
35+
return nil, nil
36+
}
3437
value := t.GetAttrValue(attr)
3538
switch value.Kind() {
3639
case reflect.Bool:

evaluation/target_test.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,13 @@ func TestTarget_GetOperator(t1 *testing.T) {
5959
"weight": 99.99,
6060
}},
6161
args: struct{ attr string }{attr: "weight"}, want: types.Number(99.99)},
62+
{name: "empty operator", fields: struct {
63+
Identifier string
64+
Name *string
65+
Anonymous bool
66+
Attributes map[string]interface{}
67+
}{Identifier: "harness", Name: nil, Anonymous: false, Attributes: map[string]interface{}{}},
68+
args: struct{ attr string }{attr: ""}, want: nil},
6269
}
6370
for _, tt := range tests {
6471
val := tt

0 commit comments

Comments
 (0)