diff --git a/utils/map_test.go b/utils/map_test.go index 6a93d4b14..6396b51fe 100644 --- a/utils/map_test.go +++ b/utils/map_test.go @@ -128,7 +128,6 @@ func TestMapSubsystemIDsFromSlice(t *testing.T) { } else if !reflect.DeepEqual(mp, eMp) { t.Errorf("Expecting: %+v, received: %+v", eMp, mp) } - } func TestMapSubsystemIDsFromSliceWithErr(t *testing.T) { @@ -137,5 +136,30 @@ func TestMapSubsystemIDsFromSliceWithErr(t *testing.T) { if _, err := MapSubsystemIDsFromSlice(sls); err != ErrUnsupportedFormat { t.Error(err) } +} + +func TestMapSubsystemIDsHasKey(t *testing.T) { + sls := []string{"*event", "*thresholds:ID1;ID2;ID3", "*attributes", "*stats:ID"} + eMp := MapSubsystemIDs{ + "*event": []string{}, + "*thresholds": []string{"ID1", "ID2", "ID3"}, + "*attributes": []string{}, + "*stats": []string{"ID"}, + } + mp, err := MapSubsystemIDsFromSlice(sls) + if err != nil { + t.Error(err) + } else if !reflect.DeepEqual(mp, eMp) { + t.Errorf("Expecting: %+v, received: %+v", eMp, mp) + } + if has := mp.HasKey("*event"); !has { + t.Errorf("Expecting: true, received: %+v", has) + } + if has := mp.HasKey("*thresholds"); !has { + t.Errorf("Expecting: true, received: %+v", has) + } + if has := mp.HasKey("*resources"); has { + t.Errorf("Expecting: false, received: %+v", has) + } }