X-Git-Url: https://ruderich.org/simon/gitweb/?a=blobdiff_plain;f=cmd%2Fsafcm%2Fsync_sync_test.go;h=5c415e368e777d71d8952ed1f7e9601f2a528fd2;hb=d55ef7c893c249eefafc24758c91a86c067778f5;hp=f100f35125e125fa64884086698f4aac78448d3d;hpb=6015bd22c34e8287b43b462facd5ad491296c8c2;p=safcm%2Fsafcm.git diff --git a/cmd/safcm/sync_sync_test.go b/cmd/safcm/sync_sync_test.go index f100f35..5c415e3 100644 --- a/cmd/safcm/sync_sync_test.go +++ b/cmd/safcm/sync_sync_test.go @@ -139,17 +139,17 @@ func TestHostSyncReq(t *testing.T) { Commands: []*safcm.Command{ { OrigGroup: "group", - Cmd: "echo command one", + Cmd: "echo command one", }, { OrigGroup: "group", - Cmd: "echo -n command two", + Cmd: "echo -n command two", }, }, }, []string{ "host1.example.org: 3 host groups: all group group3 host1.example.org remove", - "host1.example.org: 3 host group priorities (desc. order): host1.example.org", + "host1.example.org: 3 host group priorities (descending): host1.example.org", }, nil, }, @@ -244,11 +244,11 @@ func TestHostSyncReq(t *testing.T) { Commands: []*safcm.Command{ { OrigGroup: "group", - Cmd: "echo command one", + Cmd: "echo command one", }, { OrigGroup: "group", - Cmd: "echo -n command two", + Cmd: "echo -n command two", }, }, }, @@ -265,9 +265,9 @@ func TestHostSyncReq(t *testing.T) { safcm.MsgSyncReq{}, []string{ "host1.example.org: 3 host groups: all dns host1.example.org", - "host1.example.org: 3 host group priorities (desc. order): host1.example.org", + "host1.example.org: 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 \"/etc/resolv.conf\"\nUse 'group_priority' in config.yaml to declare preference"), }, { "conflict: file from detected group", @@ -280,9 +280,9 @@ func TestHostSyncReq(t *testing.T) { safcm.MsgSyncReq{}, []string{ "host2.example.org: 3 host groups: all detected_other host2.example.org other", - "host2.example.org: 3 host group priorities (desc. order): host2.example.org", + "host2.example.org: 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 \"/etc/resolv.conf\"\nUse 'group_priority' in config.yaml to declare preference"), }, { @@ -294,9 +294,9 @@ func TestHostSyncReq(t *testing.T) { safcm.MsgSyncReq{}, []string{ "host1.example.org: 3 host groups: all dns host1.example.org", - "host1.example.org: 3 host group priorities (desc. order): host1.example.org", + "host1.example.org: 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 \"/etc\"\nUse 'group_priority' in config.yaml to declare preference"), }, { "conflict: dir from detected group", @@ -309,9 +309,9 @@ func TestHostSyncReq(t *testing.T) { safcm.MsgSyncReq{}, []string{ "host2.example.org: 3 host groups: all detected_other host2.example.org other", - "host2.example.org: 3 host group priorities (desc. order): host2.example.org", + "host2.example.org: 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 \"/etc\"\nUse 'group_priority' in config.yaml to declare preference"), }, { @@ -326,8 +326,8 @@ func TestHostSyncReq(t *testing.T) { }, { - "group_order", - "project-group_order", + "group_priority", + "project-group_priority", "host1.example.org", nil, safcm.LogDebug3, @@ -422,12 +422,45 @@ func TestHostSyncReq(t *testing.T) { }, []string{ "host1.example.org: 3 host groups: all group-a group-b host1.example.org", - "host1.example.org: 3 host group priorities (desc. order): host1.example.org group-a group-b all", + "host1.example.org: 3 host group priorities (descending): host1.example.org group-a group-b all", `host1.example.org: 4 files: "/etc": group group-a overwrites triggers from group group-b`, `host1.example.org: 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: 3 host groups: all group-a group-b host1.example.org", + "host1.example.org: 3 host group priorities (descending): host1.example.org group-a", + }, + nil, + }, } for _, tc := range tests { @@ -482,7 +515,6 @@ func TestHostSyncReq(t *testing.T) { } res, err := s.hostSyncReq(tc.detected) - testutil.AssertEqual(t, "res", res, tc.exp) testutil.AssertErrorEqual(t, "err", err, tc.expErr)