]> ruderich.org/simon Gitweb - safcm/safcm.git/blobdiff - cmd/safcm/sync_sync_test.go
sync: remove duplicate "priority" from group priority log message
[safcm/safcm.git] / cmd / safcm / sync_sync_test.go
index 1294a452dc65bbff13d74852789efdf356cc75e6..f0e7524e8186a6d803c6d8e5ac326e95f722a93e 100644 (file)
@@ -138,16 +138,18 @@ func TestHostSyncReq(t *testing.T) {
                                },
                                Commands: []*safcm.Command{
                                        {
-                                               Cmd: "echo command one",
+                                               OrigGroup: "group",
+                                               Cmd:       "echo command one",
                                        },
                                        {
-                                               Cmd: "echo -n command two",
+                                               OrigGroup: "group",
+                                               Cmd:       "echo -n command two",
                                        },
                                },
                        },
                        []string{
                                "host1.example.org: <nil> 3 host groups: all group group3 host1.example.org remove",
-                               "host1.example.org: <nil> 3 host group priorities (desc. order): host1.example.org",
+                               "host1.example.org: <nil> 3 host group priorities (descending): host1.example.org",
                        },
                        nil,
                },
@@ -241,10 +243,12 @@ func TestHostSyncReq(t *testing.T) {
                                },
                                Commands: []*safcm.Command{
                                        {
-                                               Cmd: "echo command one",
+                                               OrigGroup: "group",
+                                               Cmd:       "echo command one",
                                        },
                                        {
-                                               Cmd: "echo -n command two",
+                                               OrigGroup: "group",
+                                               Cmd:       "echo -n command two",
                                        },
                                },
                        },
@@ -261,9 +265,9 @@ func TestHostSyncReq(t *testing.T) {
                        safcm.MsgSyncReq{},
                        []string{
                                "host1.example.org: <nil> 3 host groups: all dns host1.example.org",
-                               "host1.example.org: <nil> 3 host group priorities (desc. order): host1.example.org",
+                               "host1.example.org: <nil> 3 host group priorities (descending): host1.example.org",
                        },
-                       fmt.Errorf("groups dns and all both provide file \"/etc/resolv.conf\"\nUse 'group_order' in config.yaml to declare preference"),
+                       fmt.Errorf("groups dns and all both provide file \"/etc/resolv.conf\"\nUse 'group_priority' in config.yaml to declare preference"),
                },
                {
                        "conflict: file from detected group",
@@ -276,9 +280,9 @@ func TestHostSyncReq(t *testing.T) {
                        safcm.MsgSyncReq{},
                        []string{
                                "host2.example.org: <nil> 3 host groups: all detected_other host2.example.org other",
-                               "host2.example.org: <nil> 3 host group priorities (desc. order): host2.example.org",
+                               "host2.example.org: <nil> 3 host group priorities (descending): host2.example.org",
                        },
-                       fmt.Errorf("groups other and all both provide file \"/etc/resolv.conf\"\nUse 'group_order' in config.yaml to declare preference"),
+                       fmt.Errorf("groups other and all both provide file \"/etc/resolv.conf\"\nUse 'group_priority' in config.yaml to declare preference"),
                },
 
                {
@@ -290,9 +294,9 @@ func TestHostSyncReq(t *testing.T) {
                        safcm.MsgSyncReq{},
                        []string{
                                "host1.example.org: <nil> 3 host groups: all dns host1.example.org",
-                               "host1.example.org: <nil> 3 host group priorities (desc. order): host1.example.org",
+                               "host1.example.org: <nil> 3 host group priorities (descending): host1.example.org",
                        },
-                       fmt.Errorf("groups dns and all both provide file \"/etc\"\nUse 'group_order' in config.yaml to declare preference"),
+                       fmt.Errorf("groups dns and all both provide file \"/etc\"\nUse 'group_priority' in config.yaml to declare preference"),
                },
                {
                        "conflict: dir from detected group",
@@ -305,9 +309,9 @@ func TestHostSyncReq(t *testing.T) {
                        safcm.MsgSyncReq{},
                        []string{
                                "host2.example.org: <nil> 3 host groups: all detected_other host2.example.org other",
-                               "host2.example.org: <nil> 3 host group priorities (desc. order): host2.example.org",
+                               "host2.example.org: <nil> 3 host group priorities (descending): host2.example.org",
                        },
-                       fmt.Errorf("groups other and all both provide file \"/etc\"\nUse 'group_order' in config.yaml to declare preference"),
+                       fmt.Errorf("groups other and all both provide file \"/etc\"\nUse 'group_priority' in config.yaml to declare preference"),
                },
 
                {
@@ -322,8 +326,8 @@ func TestHostSyncReq(t *testing.T) {
                },
 
                {
-                       "group_order",
-                       "project-group_order",
+                       "group_priority",
+                       "project-group_priority",
                        "host1.example.org",
                        nil,
                        safcm.LogDebug3,
@@ -418,12 +422,45 @@ func TestHostSyncReq(t *testing.T) {
                        },
                        []string{
                                "host1.example.org: <nil> 3 host groups: all group-a group-b host1.example.org",
-                               "host1.example.org: <nil> 3 host group priorities (desc. order): host1.example.org group-a group-b all",
+                               "host1.example.org: <nil> 3 host group priorities (descending): host1.example.org group-a group-b all",
                                `host1.example.org: <nil> 4 files: "/etc": group group-a overwrites triggers from group group-b`,
                                `host1.example.org: <nil> 4 files: "/etc": group host1.example.org overwrites triggers from group group-a`,
                        },
                        nil,
                },
+
+               {
+                       "group_priority (single group)",
+                       "project-group_priority-single",
+                       "host1.example.org",
+                       nil,
+                       safcm.LogDebug3,
+                       safcm.MsgSyncReq{
+                               Groups: []string{"all", "group-b", "group-a", "host1.example.org"},
+                               Files: map[string]*safcm.File{
+                                       "/": {
+                                               Path:      "/",
+                                               Mode:      fs.ModeDir | 0755,
+                                               Uid:       -1,
+                                               Gid:       -1,
+                                               OrigGroup: "group-a",
+                                       },
+                                       "/file.txt": {
+                                               Path:      "/file.txt",
+                                               Mode:      0644,
+                                               Uid:       -1,
+                                               Gid:       -1,
+                                               Data:      []byte("file.txt: from group-a\n"),
+                                               OrigGroup: "group-a",
+                                       },
+                               },
+                       },
+                       []string{
+                               "host1.example.org: <nil> 3 host groups: all group-a group-b host1.example.org",
+                               "host1.example.org: <nil> 3 host group priorities (descending): host1.example.org group-a",
+                       },
+                       nil,
+               },
        }
 
        for _, tc := range tests {