tests := []struct {
name string
dryRun bool
+ quiet bool
isTTY bool
resp safcm.MsgSyncResp
exp string
"no changes",
false,
false,
+ false,
safcm.MsgSyncResp{},
- "",
+ "no changes",
},
{
"changes",
false,
false,
+ false,
safcm.MsgSyncResp{
FileChanges: []safcm.FileChange{
{
},
"\nchanged 1 file(s):\n\"created\": created, file, user(1000) group(2000), 0644\n\ninstalled 2 package(s):\n\"package-one\"\n\"package-two\"\n\nmodified 3 service(s):\n\"service-one\": started\n\"service-two\": enabled\n\"service-three\": started, enabled\n\nexecuted 2 command(s):\n\"fake command\":\n > fake output\n > \\ No newline at end of file\n\"fake command with no output\"\n",
},
+
+ {
+ "command changes only, dry-run",
+ true,
+ false,
+ false,
+ safcm.MsgSyncResp{
+ CommandChanges: []safcm.CommandChange{
+ {
+ Command: "fake command",
+ },
+ {
+ Command: "fake command with no output",
+ },
+ {
+ Command: "fake command with newline",
+ },
+ {
+ Command: "fake command with more output",
+ },
+ {
+ Command: "fake failed command",
+ },
+ },
+ },
+ "\nexecuted 5 command(s): (dry-run)\n\"fake command\"\n\"fake command with no output\"\n\"fake command with newline\"\n\"fake command with more output\"\n\"fake failed command\"\n",
+ },
+ {
+ "command changes only, quiet & dry-run",
+ true,
+ true,
+ false,
+ safcm.MsgSyncResp{
+ CommandChanges: []safcm.CommandChange{
+ {
+ Command: "fake command",
+ },
+ {
+ Command: "fake command with no output",
+ },
+ {
+ Command: "fake command with newline",
+ },
+ {
+ Command: "fake command with more output",
+ },
+ {
+ Command: "fake failed command",
+ },
+ },
+ },
+ "executed 5 command(s) (dry-run)\n",
+ },
}
for _, tc := range tests {
s := &Sync{
config: &config.Config{
DryRun: tc.dryRun,
+ Quiet: tc.quiet,
},
isTTY: tc.isTTY,
}
Command: "fake failed command",
},
},
- `executed 5 command(s): (dry-run)
-"fake command"
-"fake command with no output"
-"fake command with newline"
-"fake command with more output"
-"fake failed command"
+ `executed 5 command(s) (dry-run)
`,
},