]> ruderich.org/simon Gitweb - safcm/safcm.git/blobdiff - cmd/safcm/config/groups_test.go
config: return map from TransitivelyDetectedGroups()
[safcm/safcm.git] / cmd / safcm / config / groups_test.go
index 28aa82f7c9d02be4836b743e5f53528e12b2a4cc..7c3dd483393e9dbb5791004633358912c705285b 100644 (file)
@@ -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\""),
                },
 
                {
@@ -186,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",
@@ -332,7 +332,7 @@ func TestTransitivelyDetectedGroups(t *testing.T) {
        tests := []struct {
                name   string
                groups map[string][]string
-               exp    []string
+               exp    map[string]bool
        }{
 
                {
@@ -351,7 +351,7 @@ func TestTransitivelyDetectedGroups(t *testing.T) {
                                        "d",
                                },
                        },
-                       nil,
+                       map[string]bool{},
                },
 
                {
@@ -367,8 +367,8 @@ func TestTransitivelyDetectedGroups(t *testing.T) {
                                        "d",
                                },
                        },
-                       []string{
-                               "group-a",
+                       map[string]bool{
+                               "group-a": true,
                        },
                },
 
@@ -389,8 +389,8 @@ func TestTransitivelyDetectedGroups(t *testing.T) {
                                        "d",
                                },
                        },
-                       []string{
-                               "group-a",
+                       map[string]bool{
+                               "group-a": true,
                        },
                },
 
@@ -418,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,
                        },
                },
 
@@ -453,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,
                        },
                },
        }