Skip to content

Commit

Permalink
added exclusive value filter nested array test
Browse files Browse the repository at this point in the history
  • Loading branch information
TheFireMike committed Dec 15, 2021
1 parent d2a7b6a commit d700861
Showing 1 changed file with 40 additions and 1 deletion.
41 changes: 40 additions & 1 deletion internal/deviceclass/groupproperty/filter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,7 @@ func TestValueFilter_ApplyPropertyGroups_nestedArray(t *testing.T) {
propertyGroup{
"ifIndex": "1",
"ifDescr": "Ethernet #1",
"radio": []propertyGroup{
"radio": PropertyGroups{
{
"level_in": "10",
"level_out": "10",
Expand Down Expand Up @@ -592,6 +592,45 @@ func TestExclusiveValueFilter_ApplyPropertyGroups_nested(t *testing.T) {
assert.Equal(t, expected, filteredGroup)
}

func TestExclusiveValueFilter_ApplyPropertyGroups_nestedArray(t *testing.T) {
filter := GetExclusiveValueFilter([][]string{{"radio", "level_in"}})

groups := PropertyGroups{
propertyGroup{
"ifIndex": "1",
"ifDescr": "Ethernet #1",
"radio": PropertyGroups{
{
"level_in": "10",
"level_out": "10",
},
{
"level_in": "7",
"level_out": "5",
},
},
},
}

filteredGroup, err := filter.ApplyPropertyGroups(context.Background(), groups)
assert.NoError(t, err)

expected := PropertyGroups{
propertyGroup{
"radio": PropertyGroups{
{
"level_in": "10",
},
{
"level_in": "7",
},
},
},
}

assert.Equal(t, expected, filteredGroup)
}

func TestExclusiveValueFilter_ApplyPropertyGroups_multipleNested(t *testing.T) {
filter := GetExclusiveValueFilter([][]string{{"radio", "level_in"}, {"radio", "level_out"}})

Expand Down

0 comments on commit d700861

Please sign in to comment.