]> ruderich.org/simon Gitweb - safcm/safcm.git/commitdiff
tests: use consistent order of safcm.File struct members
authorSimon Ruderich <simon@ruderich.org>
Sun, 6 Mar 2022 09:04:45 +0000 (10:04 +0100)
committerSimon Ruderich <simon@ruderich.org>
Sun, 6 Mar 2022 09:04:45 +0000 (10:04 +0100)
cmd/safcm/sync_sync_test.go
remote/sync/commands_test.go
remote/sync/files_test.go

index 2214e0ebfa98ebabd473c452d61a3ff3e8a239e2..8ef0113f269012e2506a1dd70b17fbaae76c4e86 100644 (file)
@@ -62,8 +62,9 @@ func TestHostSyncReq(t *testing.T) {
                                        "host1.example.org",
                                },
                                Files: map[string]*safcm.File{
-                                       "/": {Path: "/",
+                                       "/": {
                                                OrigGroup: "group",
+                                               Path:      "/",
                                                Mode:      fs.ModeDir | 0755 | fs.ModeSetgid,
                                                Uid:       -1,
                                                Gid:       -1,
@@ -225,26 +226,26 @@ func TestHostSyncReq(t *testing.T) {
                                Groups: []string{"all", "group-b", "group-a", "host1.example.org"},
                                Files: map[string]*safcm.File{
                                        "/": {
+                                               OrigGroup: "host1.example.org",
                                                Path:      "/",
                                                Mode:      fs.ModeDir | 0755,
                                                Uid:       -1,
                                                Gid:       -1,
-                                               OrigGroup: "host1.example.org",
                                        },
                                        "/etc": {
+                                               OrigGroup: "host1.example.org",
                                                Path:      "/etc",
                                                Mode:      fs.ModeDir | 0755,
                                                Uid:       -1,
                                                Gid:       -1,
-                                               OrigGroup: "host1.example.org",
                                        },
                                        "/etc/dir-to-file": {
+                                               OrigGroup: "group-a",
                                                Path:      "/etc/dir-to-file",
                                                Mode:      0644,
                                                Uid:       -1,
                                                Gid:       -1,
                                                Data:      []byte("dir-to-file: from group-a\n"),
-                                               OrigGroup: "group-a",
                                        },
                                        "/etc/dir-to-filex": {
                                                OrigGroup: "group-b",
@@ -255,12 +256,12 @@ func TestHostSyncReq(t *testing.T) {
                                                Data:      []byte("dir-to-filex\n"),
                                        },
                                        "/etc/dir-to-link": {
+                                               OrigGroup: "group-a",
                                                Path:      "/etc/dir-to-link",
                                                Mode:      fs.ModeSymlink | 0777,
                                                Uid:       -1,
                                                Gid:       -1,
                                                Data:      []byte("target"),
-                                               OrigGroup: "group-a",
                                        },
                                        "/etc/dir-to-linkx": {
                                                OrigGroup: "group-b",
@@ -271,42 +272,42 @@ func TestHostSyncReq(t *testing.T) {
                                                Data:      []byte("dir-to-linkx\n"),
                                        },
                                        "/etc/file-to-dir": {
+                                               OrigGroup: "group-a",
                                                Path:      "/etc/file-to-dir",
                                                Mode:      fs.ModeDir | 0755,
                                                Uid:       -1,
                                                Gid:       -1,
-                                               OrigGroup: "group-a",
                                        },
                                        "/etc/file-to-dir/file": {
+                                               OrigGroup: "group-a",
                                                Path:      "/etc/file-to-dir/file",
                                                Mode:      0644,
                                                Uid:       -1,
                                                Gid:       -1,
                                                Data:      []byte("file: from group-a\n"),
-                                               OrigGroup: "group-a",
                                        },
                                        "/etc/file-to-dir/dir": {
+                                               OrigGroup: "group-a",
                                                Path:      "/etc/file-to-dir/dir",
                                                Mode:      fs.ModeDir | 0755,
                                                Uid:       -1,
                                                Gid:       -1,
-                                               OrigGroup: "group-a",
                                        },
                                        "/etc/file-to-dir/dir/file2": {
+                                               OrigGroup: "group-a",
                                                Path:      "/etc/file-to-dir/dir/file2",
                                                Mode:      0644,
                                                Uid:       -1,
                                                Gid:       -1,
                                                Data:      []byte("file2: from group-a\n"),
-                                               OrigGroup: "group-a",
                                        },
                                        "/etc/motd": {
+                                               OrigGroup: "host1.example.org",
                                                Path:      "/etc/motd",
                                                Mode:      0644,
                                                Uid:       -1,
                                                Gid:       -1,
                                                Data:      []byte("motd: from host1\n"),
-                                               OrigGroup: "host1.example.org",
                                        },
                                },
                        },
@@ -328,19 +329,19 @@ func TestHostSyncReq(t *testing.T) {
                                Groups: []string{"all", "group-b", "group-a", "host1.example.org"},
                                Files: map[string]*safcm.File{
                                        "/": {
+                                               OrigGroup: "group-a",
                                                Path:      "/",
                                                Mode:      fs.ModeDir | 0755,
                                                Uid:       -1,
                                                Gid:       -1,
-                                               OrigGroup: "group-a",
                                        },
                                        "/file.txt": {
+                                               OrigGroup: "group-a",
                                                Path:      "/file.txt",
                                                Mode:      0644,
                                                Uid:       -1,
                                                Gid:       -1,
                                                Data:      []byte("file.txt: from group-a\n"),
-                                               OrigGroup: "group-a",
                                        },
                                },
                        },
index 4d60dda0074923b82a8f3aba3875f6cafd3c9192..fcb628ed631860a695913027eb2a9331a57b76ff 100644 (file)
@@ -308,32 +308,32 @@ func TestSyncCommands(t *testing.T) {
                                },
                                Files: map[string]*safcm.File{
                                        ".": {
+                                               OrigGroup: "group",
                                                Path:      ".",
                                                Mode:      fs.ModeDir | 0700,
                                                Uid:       -1,
                                                Gid:       -1,
-                                               OrigGroup: "group",
                                                TriggerCommands: []string{
                                                        "echo trigger .",
                                                },
                                        },
                                        "dir": {
+                                               OrigGroup: "group",
                                                Path:      "dir",
                                                Mode:      fs.ModeDir | 0755,
                                                Uid:       -1,
                                                Gid:       -1,
-                                               OrigGroup: "group",
                                                TriggerCommands: []string{
                                                        "echo trigger dir",
                                                },
                                        },
                                        "dir/file": {
+                                               OrigGroup: "group",
                                                Path:      "dir/file",
                                                Mode:      0644,
                                                Uid:       -1,
                                                Gid:       -1,
                                                Data:      []byte("content\n"),
-                                               OrigGroup: "group",
                                                TriggerCommands: []string{
                                                        "echo trigger dir/file",
                                                },
@@ -427,32 +427,32 @@ func TestSyncCommands(t *testing.T) {
                                },
                                Files: map[string]*safcm.File{
                                        ".": {
+                                               OrigGroup: "group",
                                                Path:      ".",
                                                Mode:      fs.ModeDir | 0700,
                                                Uid:       -1,
                                                Gid:       -1,
-                                               OrigGroup: "group",
                                                TriggerCommands: []string{
                                                        "echo trigger .",
                                                },
                                        },
                                        "dir": {
+                                               OrigGroup: "group",
                                                Path:      "dir",
                                                Mode:      fs.ModeDir | 0755,
                                                Uid:       -1,
                                                Gid:       -1,
-                                               OrigGroup: "group",
                                                TriggerCommands: []string{
                                                        "false",
                                                },
                                        },
                                        "dir/file": {
+                                               OrigGroup: "group",
                                                Path:      "dir/file",
                                                Mode:      0644,
                                                Uid:       -1,
                                                Gid:       -1,
                                                Data:      []byte("content\n"),
-                                               OrigGroup: "group",
                                                TriggerCommands: []string{
                                                        "echo trigger dir/file",
                                                },
index 48d54fca062812974317958ae28ecbc8c77c0776..ded6614e2c35fbc246658ceff4a1bd951590a500 100644 (file)
@@ -81,26 +81,26 @@ func TestSyncFiles(t *testing.T) {
                        safcm.MsgSyncReq{
                                Files: map[string]*safcm.File{
                                        ".": {
+                                               OrigGroup: "group",
                                                Path:      ".",
                                                Mode:      fs.ModeDir | 0700,
                                                Uid:       -1,
                                                Gid:       -1,
-                                               OrigGroup: "group",
                                        },
                                        "dir": {
+                                               OrigGroup: "group",
                                                Path:      "dir",
                                                Mode:      fs.ModeDir | 0755,
                                                Uid:       -1,
                                                Gid:       -1,
-                                               OrigGroup: "group",
                                        },
                                        "dir/file": {
+                                               OrigGroup: "group",
                                                Path:      "dir/file",
                                                Mode:      0644,
                                                Uid:       -1,
                                                Gid:       -1,
                                                Data:      []byte("content\n"),
-                                               OrigGroup: "group",
                                        },
                                },
                        },
@@ -165,26 +165,26 @@ func TestSyncFiles(t *testing.T) {
                        safcm.MsgSyncReq{
                                Files: map[string]*safcm.File{
                                        ".": {
+                                               OrigGroup: "group",
                                                Path:      ".",
                                                Mode:      fs.ModeDir | 0700,
                                                Uid:       -1,
                                                Gid:       -1,
-                                               OrigGroup: "group",
                                        },
                                        "dir": {
+                                               OrigGroup: "group",
                                                Path:      "dir",
                                                Mode:      fs.ModeDir | 0755,
                                                Uid:       -1,
                                                Gid:       -1,
-                                               OrigGroup: "group",
                                        },
                                        "dir/file": {
+                                               OrigGroup: "group",
                                                Path:      "dir/file",
                                                Mode:      0644,
                                                Uid:       -1,
                                                Gid:       -1,
                                                Data:      []byte("content\n"),
-                                               OrigGroup: "group",
                                        },
                                },
                        },
@@ -220,12 +220,12 @@ func TestSyncFiles(t *testing.T) {
                        safcm.MsgSyncReq{
                                Files: map[string]*safcm.File{
                                        ".": {
+                                               OrigGroup: "group",
                                                Path:      ".",
                                                Mode:      fs.ModeDir | 0700,
                                                User:      "user",
                                                Uid:       1,
                                                Gid:       -1,
-                                               OrigGroup: "group",
                                        },
                                },
                        },
@@ -244,12 +244,12 @@ func TestSyncFiles(t *testing.T) {
                        safcm.MsgSyncReq{
                                Files: map[string]*safcm.File{
                                        ".": {
+                                               OrigGroup: "group",
                                                Path:      ".",
                                                Mode:      fs.ModeDir | 0700,
                                                Uid:       -1,
                                                Group:     "group",
                                                Gid:       1,
-                                               OrigGroup: "group",
                                        },
                                },
                        },
@@ -276,25 +276,25 @@ func TestSyncFiles(t *testing.T) {
                        safcm.MsgSyncReq{
                                Files: map[string]*safcm.File{
                                        "/": {
+                                               OrigGroup: "group",
                                                Path:      "/",
                                                Mode:      fs.ModeDir | 0755,
                                                Uid:       0,
                                                Gid:       0,
-                                               OrigGroup: "group",
                                        },
                                        "/etc": {
+                                               OrigGroup: "group",
                                                Path:      "/etc",
                                                Mode:      fs.ModeDir | 0755,
                                                Uid:       0,
                                                Gid:       0,
-                                               OrigGroup: "group",
                                        },
                                        "/tmp": {
+                                               OrigGroup: "group",
                                                Path:      "/tmp",
                                                Mode:      fs.ModeDir | 0777 | fs.ModeSticky,
                                                Uid:       0,
                                                Gid:       0,
-                                               OrigGroup: "group",
                                        },
                                },
                        },
@@ -318,32 +318,32 @@ func TestSyncFiles(t *testing.T) {
                        safcm.MsgSyncReq{
                                Files: map[string]*safcm.File{
                                        ".": {
+                                               OrigGroup: "group",
                                                Path:      ".",
                                                Mode:      fs.ModeDir | 0700,
                                                Uid:       -1,
                                                Gid:       -1,
-                                               OrigGroup: "group",
                                                TriggerCommands: []string{
                                                        "echo trigger .",
                                                },
                                        },
                                        "dir": {
+                                               OrigGroup: "group",
                                                Path:      "dir",
                                                Mode:      fs.ModeDir | 0755,
                                                Uid:       -1,
                                                Gid:       -1,
-                                               OrigGroup: "group",
                                                TriggerCommands: []string{
                                                        "echo trigger dir",
                                                },
                                        },
                                        "dir/file": {
+                                               OrigGroup: "group",
                                                Path:      "dir/file",
                                                Mode:      0644,
                                                Uid:       -1,
                                                Gid:       -1,
                                                Data:      []byte("content\n"),
-                                               OrigGroup: "group",
                                                TriggerCommands: []string{
                                                        "echo trigger dir/file",
                                                },
@@ -382,32 +382,32 @@ func TestSyncFiles(t *testing.T) {
                        safcm.MsgSyncReq{
                                Files: map[string]*safcm.File{
                                        ".": {
+                                               OrigGroup: "group",
                                                Path:      ".",
                                                Mode:      fs.ModeDir | 0700,
                                                Uid:       -1,
                                                Gid:       -1,
-                                               OrigGroup: "group",
                                                TriggerCommands: []string{
                                                        "echo trigger .",
                                                },
                                        },
                                        "dir": {
+                                               OrigGroup: "group",
                                                Path:      "dir",
                                                Mode:      fs.ModeDir | 0755,
                                                Uid:       -1,
                                                Gid:       -1,
-                                               OrigGroup: "group",
                                                TriggerCommands: []string{
                                                        "echo trigger dir",
                                                },
                                        },
                                        "dir/file": {
+                                               OrigGroup: "group",
                                                Path:      "dir/file",
                                                Mode:      0644,
                                                Uid:       -1,
                                                Gid:       -1,
                                                Data:      []byte("content\n"),
-                                               OrigGroup: "group",
                                                TriggerCommands: []string{
                                                        "echo trigger dir/file",
                                                },
@@ -472,32 +472,32 @@ func TestSyncFiles(t *testing.T) {
                        safcm.MsgSyncReq{
                                Files: map[string]*safcm.File{
                                        ".": {
+                                               OrigGroup: "group",
                                                Path:      ".",
                                                Mode:      fs.ModeDir | 0700,
                                                Uid:       -1,
                                                Gid:       -1,
-                                               OrigGroup: "group",
                                                TriggerCommands: []string{
                                                        "echo trigger .",
                                                },
                                        },
                                        "dir": {
+                                               OrigGroup: "group",
                                                Path:      "dir",
                                                Mode:      fs.ModeDir | 0755,
                                                Uid:       -1,
                                                Gid:       -1,
-                                               OrigGroup: "group",
                                                TriggerCommands: []string{
                                                        "echo trigger dir",
                                                },
                                        },
                                        "dir/file": {
+                                               OrigGroup: "group",
                                                Path:      "dir/file",
                                                Mode:      0644,
                                                Uid:       -1,
                                                Gid:       -1,
                                                Data:      []byte("content\n"),
-                                               OrigGroup: "group",
                                                TriggerCommands: []string{
                                                        "echo trigger dir/file",
                                                },
@@ -563,32 +563,32 @@ func TestSyncFiles(t *testing.T) {
                        safcm.MsgSyncReq{
                                Files: map[string]*safcm.File{
                                        ".": {
+                                               OrigGroup: "group",
                                                Path:      ".",
                                                Mode:      fs.ModeDir | 0700,
                                                Uid:       -1,
                                                Gid:       -1,
-                                               OrigGroup: "group",
                                                TriggerCommands: []string{
                                                        "echo trigger .",
                                                },
                                        },
                                        "dir": {
+                                               OrigGroup: "group",
                                                Path:      "dir",
                                                Mode:      fs.ModeDir | 0755,
                                                Uid:       -1,
                                                Gid:       -1,
-                                               OrigGroup: "group",
                                                TriggerCommands: []string{
                                                        "echo trigger dir",
                                                },
                                        },
                                        "dir/file": {
+                                               OrigGroup: "group",
                                                Path:      "dir/file",
                                                Mode:      0644,
                                                Uid:       -1,
                                                Gid:       -1,
                                                Data:      []byte("content\n"),
-                                               OrigGroup: "group",
                                                TriggerCommands: []string{
                                                        "echo trigger dir/file",
                                                },
@@ -650,32 +650,32 @@ func TestSyncFiles(t *testing.T) {
                        safcm.MsgSyncReq{
                                Files: map[string]*safcm.File{
                                        ".": {
+                                               OrigGroup: "group",
                                                Path:      ".",
                                                Mode:      fs.ModeDir | 0700,
                                                Uid:       -1,
                                                Gid:       -1,
-                                               OrigGroup: "group",
                                                TriggerCommands: []string{
                                                        "echo trigger .",
                                                },
                                        },
                                        "dir": {
+                                               OrigGroup: "group",
                                                Path:      "dir",
                                                Mode:      fs.ModeDir | 0755,
                                                Uid:       -1,
                                                Gid:       -1,
-                                               OrigGroup: "group",
                                                TriggerCommands: []string{
                                                        "echo trigger dir",
                                                },
                                        },
                                        "dir/file": {
+                                               OrigGroup: "group",
                                                Path:      "dir/file",
                                                Mode:      0644,
                                                Uid:       -1,
                                                Gid:       -1,
                                                Data:      []byte("content\n"),
-                                               OrigGroup: "group",
                                                TriggerCommands: []string{
                                                        "echo trigger dir/file",
                                                },
@@ -752,31 +752,31 @@ func TestSyncFiles(t *testing.T) {
                        safcm.MsgSyncReq{
                                Files: map[string]*safcm.File{
                                        "/": {
+                                               OrigGroup: "group",
                                                Path:      "/",
                                                Mode:      fs.ModeDir | 0755,
                                                Uid:       0,
                                                Gid:       0,
-                                               OrigGroup: "group",
                                                TriggerCommands: []string{
                                                        "echo trigger /",
                                                },
                                        },
                                        "/tmp": {
+                                               OrigGroup: "group",
                                                Path:      "/tmp",
                                                Mode:      fs.ModeDir | 0777 | fs.ModeSticky,
                                                Uid:       0,
                                                Gid:       0,
-                                               OrigGroup: "group",
                                                TriggerCommands: []string{
                                                        "echo trigger /tmp",
                                                },
                                        },
                                        tmpTestFilePath: {
+                                               OrigGroup: "group",
                                                Path:      tmpTestFilePath,
                                                Mode:      0600,
                                                Uid:       -1,
                                                Gid:       -1,
-                                               OrigGroup: "group",
                                                TriggerCommands: []string{
                                                        "echo trigger /tmp/file",
                                                },