Skip to content

Commit

Permalink
Add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
jesusfcr committed Apr 30, 2024
1 parent 34fbb4a commit 3472e9f
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
17 changes: 17 additions & 0 deletions cmd/foreach/foreach_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,23 @@ func TestItRunsCommandInShellAgainstWorkingCopies(t *testing.T) {
})
}

func TestItRunsCommandQuotedInShellAgainstWorkingCopied(t *testing.T) {
fakeExecutor := executor.NewAlwaysSucceedsFakeExecutor()
exec = fakeExecutor

testsupport.PrepareTempCampaign(true, "org/repo1", "org/repo2")

out, err := runCommand("some", "command", "with spaces")
assert.NoError(t, err)
assert.Contains(t, out, "turbolift foreach completed")
assert.Contains(t, out, "2 OK, 0 skipped")

fakeExecutor.AssertCalledWith(t, [][]string{
{"work/org/repo1", userShell(), "-c", "some command \"with spaces\""},
{"work/org/repo2", userShell(), "-c", "some command \"with spaces\""},
})
}

func TestItSkipsMissingWorkingCopies(t *testing.T) {
fakeExecutor := executor.NewAlwaysSucceedsFakeExecutor()
exec = fakeExecutor
Expand Down
2 changes: 1 addition & 1 deletion internal/executor/executor.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ func summarizedArgs(args []string) []string {
result := []string{}
for _, arg := range args {
if len(arg) > 30 {
result = append(result, "...")
result = append(result, arg[:27]+"...")
} else {
result = append(result, arg)
}
Expand Down

0 comments on commit 3472e9f

Please sign in to comment.