X-Git-Url: https://ruderich.org/simon/gitweb/?a=blobdiff_plain;f=cmd%2Fsafcm%2Fconfig%2Fgroups_test.go;h=7c3dd483393e9dbb5791004633358912c705285b;hb=77f373a4aa590711155e3af0b768997781f81559;hp=57176079bc0782ebfc0a76fb2f59bc84d0a27391;hpb=4473e968425319e6beae558643bb047a6b01c17a;p=safcm%2Fsafcm.git diff --git a/cmd/safcm/config/groups_test.go b/cmd/safcm/config/groups_test.go index 5717607..7c3dd48 100644 --- a/cmd/safcm/config/groups_test.go +++ b/cmd/safcm/config/groups_test.go @@ -55,7 +55,7 @@ func TestLoadGroups(t *testing.T) { { "../testdata/project", &Config{ - GroupOrder: []string{ + GroupPriority: []string{ "detected_linux", "detected_freebsd", }, @@ -105,38 +105,38 @@ func TestLoadGroups(t *testing.T) { { "../testdata/project", &Config{ - GroupOrder: []string{ + GroupPriority: []string{ "detected_freebsd", "does-not-exist", }, }, hosts, nil, - fmt.Errorf("config.yaml: group_order: group \"does-not-exist\" does not exist"), + fmt.Errorf("config.yaml: group_priority: group \"does-not-exist\" does not exist"), }, { "../testdata/project", &Config{ - GroupOrder: []string{ + GroupPriority: []string{ "detected_freebsd", "special:group", }, }, hosts, nil, - fmt.Errorf("config.yaml: group_order: invalid group name \"special:group\""), + fmt.Errorf("config.yaml: group_priority: invalid group name \"special:group\""), }, { "../testdata/project", &Config{ - GroupOrder: []string{ + GroupPriority: []string{ "detected_freebsd", "group:remove", }, }, hosts, nil, - fmt.Errorf("config.yaml: group_order: invalid group name \"group:remove\""), + fmt.Errorf("config.yaml: group_priority: invalid group name \"group:remove\""), }, { @@ -160,6 +160,13 @@ func TestLoadGroups(t *testing.T) { nil, fmt.Errorf("groups.yaml: group \"host2\": conflict with existing host"), }, + { + "../testdata/group-invalid-conflict-remove", + &Config{}, + hosts, + nil, + fmt.Errorf("groups.yaml: group \"host2:remove\": conflict with existing host"), + }, { "../testdata/group-invalid-detected", &Config{}, @@ -179,7 +186,7 @@ func TestLoadGroups(t *testing.T) { &Config{}, &Hosts{}, nil, - fmt.Errorf("groups.yaml: group \"1group2\": group \"does-not-exist\" not found"), + fmt.Errorf("groups.yaml: group \"1group2\": member \"does-not-exist\" not found"), }, { "../testdata/group-invalid-name", @@ -325,7 +332,7 @@ func TestTransitivelyDetectedGroups(t *testing.T) { tests := []struct { name string groups map[string][]string - exp []string + exp map[string]bool }{ { @@ -344,7 +351,7 @@ func TestTransitivelyDetectedGroups(t *testing.T) { "d", }, }, - nil, + map[string]bool{}, }, { @@ -360,8 +367,8 @@ func TestTransitivelyDetectedGroups(t *testing.T) { "d", }, }, - []string{ - "group-a", + map[string]bool{ + "group-a": true, }, }, @@ -382,8 +389,8 @@ func TestTransitivelyDetectedGroups(t *testing.T) { "d", }, }, - []string{ - "group-a", + map[string]bool{ + "group-a": true, }, }, @@ -411,12 +418,12 @@ func TestTransitivelyDetectedGroups(t *testing.T) { "b", }, }, - []string{ - "group-a", - "group-b", - "group-c", - "group-d", - "group-e", + map[string]bool{ + "group-a": true, + "group-b": true, + "group-c": true, + "group-d": true, + "group-e": true, }, }, @@ -446,12 +453,12 @@ func TestTransitivelyDetectedGroups(t *testing.T) { "b", }, }, - []string{ - "group-a", - "group-b", - "group-c", - "group-d", - "group-e", + map[string]bool{ + "group-a": true, + "group-b": true, + "group-c": true, + "group-d": true, + "group-e": true, }, }, }