]> ruderich.org/simon Gitweb - safcm/safcm.git/blobdiff - cmd/safcm-remote/sync/commands_test.go
remote: show group/trigger in verbose log for commands
[safcm/safcm.git] / cmd / safcm-remote / sync / commands_test.go
index 142a2542a931d4191d56f0b5be641da6a2b00cd7..1c534188eae0439e6c3eda15acd816aa11376e30 100644 (file)
@@ -65,8 +65,11 @@ func TestSyncCommands(t *testing.T) {
                                        "group2",
                                        "host.example.org",
                                },
-                               Commands: []string{
-                                       "echo; env | grep SAFCM_",
+                               Commands: []*safcm.Command{
+                                       {
+                                               OrigGroup: "group",
+                                               Cmd: "echo; env | grep SAFCM_",
+                                       },
                                },
                        },
                        nil,
@@ -82,7 +85,7 @@ func TestSyncCommands(t *testing.T) {
                                Env: env,
                        }},
                        []string{
-                               `3: sync remote: commands: running "/bin/sh" "-c" "echo; env | grep SAFCM_"`,
+                               `3: sync remote: commands: running "/bin/sh" "-c" "echo; env | grep SAFCM_" (group)`,
                                "5: sync remote: commands: command output:\nfake stdout/stderr",
                        },
                        safcm.MsgSyncResp{
@@ -105,8 +108,11 @@ func TestSyncCommands(t *testing.T) {
                                        "group2",
                                        "host.example.org",
                                },
-                               Commands: []string{
-                                       "echo; env | grep SAFCM_",
+                               Commands: []*safcm.Command{
+                                       {
+                                               OrigGroup: "group",
+                                               Cmd: "echo; env | grep SAFCM_",
+                                       },
                                },
                        },
                        nil,
@@ -134,8 +140,11 @@ func TestSyncCommands(t *testing.T) {
                                        "group2",
                                        "host.example.org",
                                },
-                               Commands: []string{
-                                       "echo hi; false",
+                               Commands: []*safcm.Command{
+                                       {
+                                               OrigGroup: "group",
+                                               Cmd: "echo hi; false",
+                                       },
                                },
                        },
                        nil,
@@ -151,7 +160,7 @@ func TestSyncCommands(t *testing.T) {
                                Env: env,
                        }},
                        []string{
-                               `3: sync remote: commands: running "/bin/sh" "-c" "echo hi; false"`,
+                               `3: sync remote: commands: running "/bin/sh" "-c" "echo hi; false" (group)`,
                                "5: sync remote: commands: command output:\nfake stdout/stderr",
                        },
                        safcm.MsgSyncResp{
@@ -175,8 +184,11 @@ func TestSyncCommands(t *testing.T) {
                                        "group2",
                                        "host.example.org",
                                },
-                               Commands: []string{
-                                       "echo hi; false",
+                               Commands: []*safcm.Command{
+                                       {
+                                               OrigGroup: "group",
+                                               Cmd: "echo hi; false",
+                                       },
                                },
                        },
                        nil,
@@ -204,11 +216,20 @@ func TestSyncCommands(t *testing.T) {
                                        "group2",
                                        "host.example.org",
                                },
-                               Commands: []string{
-                                       "echo first",
-                                       "echo second",
-                                       "false",
-                                       "echo third",
+                               Commands: []*safcm.Command{
+                                       {
+                                               OrigGroup: "group1",
+                                               Cmd: "echo first",
+                                       }, {
+                                               OrigGroup: "group2",
+                                               Cmd: "echo second",
+                                       }, {
+                                               OrigGroup: "group3",
+                                               Cmd: "false",
+                                       }, {
+                                               OrigGroup: "group4",
+                                               Cmd: "echo third",
+                                       },
                                },
                        },
                        nil,
@@ -250,11 +271,11 @@ func TestSyncCommands(t *testing.T) {
                                Env: env,
                        }},
                        []string{
-                               `3: sync remote: commands: running "/bin/sh" "-c" "echo first"`,
+                               `3: sync remote: commands: running "/bin/sh" "-c" "echo first" (group1)`,
                                "5: sync remote: commands: command output:\nfake stdout/stderr first",
-                               `3: sync remote: commands: running "/bin/sh" "-c" "echo second"`,
+                               `3: sync remote: commands: running "/bin/sh" "-c" "echo second" (group2)`,
                                "5: sync remote: commands: command output:\nfake stdout/stderr second",
-                               `3: sync remote: commands: running "/bin/sh" "-c" "false"`,
+                               `3: sync remote: commands: running "/bin/sh" "-c" "false" (group3)`,
                        },
                        safcm.MsgSyncResp{
                                CommandChanges: []safcm.CommandChange{
@@ -318,8 +339,11 @@ func TestSyncCommands(t *testing.T) {
                                                },
                                        },
                                },
-                               Commands: []string{
-                                       "echo; env | grep SAFCM_",
+                               Commands: []*safcm.Command{
+                                       {
+                                               OrigGroup: "group",
+                                               Cmd: "echo; env | grep SAFCM_",
+                                       },
                                },
                        },
                        []string{
@@ -364,11 +388,11 @@ func TestSyncCommands(t *testing.T) {
                                Env: env,
                        }},
                        []string{
-                               `3: sync remote: commands: running "/bin/sh" "-c" "echo trigger ."`,
+                               `3: sync remote: commands: running "/bin/sh" "-c" "echo trigger ." (".")`,
                                "5: sync remote: commands: command output:\nfake stdout/stderr .",
-                               `3: sync remote: commands: running "/bin/sh" "-c" "echo trigger dir"`,
+                               `3: sync remote: commands: running "/bin/sh" "-c" "echo trigger dir" ("dir")`,
                                "5: sync remote: commands: command output:\nfake stdout/stderr dir",
-                               `3: sync remote: commands: running "/bin/sh" "-c" "echo; env | grep SAFCM_"`,
+                               `3: sync remote: commands: running "/bin/sh" "-c" "echo; env | grep SAFCM_" (group)`,
                                "5: sync remote: commands: command output:\nfake stdout/stderr",
                        },
                        safcm.MsgSyncResp{
@@ -434,8 +458,11 @@ func TestSyncCommands(t *testing.T) {
                                                },
                                        },
                                },
-                               Commands: []string{
-                                       "echo; env | grep SAFCM_",
+                               Commands: []*safcm.Command{
+                                       {
+                                               OrigGroup: "group",
+                                               Cmd: "echo; env | grep SAFCM_",
+                                       },
                                },
                        },
                        []string{
@@ -470,9 +497,9 @@ func TestSyncCommands(t *testing.T) {
                                Env: env,
                        }},
                        []string{
-                               `3: sync remote: commands: running "/bin/sh" "-c" "echo trigger ."`,
+                               `3: sync remote: commands: running "/bin/sh" "-c" "echo trigger ." (".")`,
                                "5: sync remote: commands: command output:\nfake stdout/stderr .",
-                               `3: sync remote: commands: running "/bin/sh" "-c" "false"`,
+                               `3: sync remote: commands: running "/bin/sh" "-c" "false" ("dir")`,
                                "5: sync remote: commands: command output:\nfake stdout/stderr dir",
                        },
                        safcm.MsgSyncResp{