test(cli): add failing pretend quiet dry-run coverage
This commit is contained in:
@@ -79,6 +79,43 @@ func (s *CLISuite) TestRun_Exec_RunsCommandInCastleRoot() {
|
|||||||
require.Empty(s.T(), s.stderr.String())
|
require.Empty(s.T(), s.stderr.String())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (s *CLISuite) TestRun_Exec_WithPretend_DoesNotExecute() {
|
||||||
|
castleRoot := filepath.Join(s.homeDir, ".homesick", "repos", "dotfiles")
|
||||||
|
require.NoError(s.T(), os.MkdirAll(castleRoot, 0o755))
|
||||||
|
target := filepath.Join(castleRoot, "should-not-exist")
|
||||||
|
|
||||||
|
exitCode := cli.Run([]string{"--pretend", "exec", "dotfiles", "touch should-not-exist"}, s.stdout, s.stderr)
|
||||||
|
|
||||||
|
require.Equal(s.T(), 0, exitCode)
|
||||||
|
require.NoFileExists(s.T(), target)
|
||||||
|
require.Contains(s.T(), s.stdout.String(), "Would execute")
|
||||||
|
require.Empty(s.T(), s.stderr.String())
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *CLISuite) TestRun_Exec_WithDryRunAlias_DoesNotExecute() {
|
||||||
|
castleRoot := filepath.Join(s.homeDir, ".homesick", "repos", "dotfiles")
|
||||||
|
require.NoError(s.T(), os.MkdirAll(castleRoot, 0o755))
|
||||||
|
target := filepath.Join(castleRoot, "should-not-exist")
|
||||||
|
|
||||||
|
exitCode := cli.Run([]string{"--dry-run", "exec", "dotfiles", "touch should-not-exist"}, s.stdout, s.stderr)
|
||||||
|
|
||||||
|
require.Equal(s.T(), 0, exitCode)
|
||||||
|
require.NoFileExists(s.T(), target)
|
||||||
|
require.Contains(s.T(), s.stdout.String(), "Would execute")
|
||||||
|
require.Empty(s.T(), s.stderr.String())
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *CLISuite) TestRun_Exec_WithQuiet_SuppressesStatusOutput() {
|
||||||
|
castleRoot := filepath.Join(s.homeDir, ".homesick", "repos", "dotfiles")
|
||||||
|
require.NoError(s.T(), os.MkdirAll(castleRoot, 0o755))
|
||||||
|
|
||||||
|
exitCode := cli.Run([]string{"--quiet", "exec", "dotfiles", "true"}, s.stdout, s.stderr)
|
||||||
|
|
||||||
|
require.Equal(s.T(), 0, exitCode)
|
||||||
|
require.Empty(s.T(), s.stdout.String())
|
||||||
|
require.Empty(s.T(), s.stderr.String())
|
||||||
|
}
|
||||||
|
|
||||||
func (s *CLISuite) TestRun_PullAll_NoCastlesIsNoop() {
|
func (s *CLISuite) TestRun_PullAll_NoCastlesIsNoop() {
|
||||||
exitCode := cli.Run([]string{"pull", "--all"}, s.stdout, s.stderr)
|
exitCode := cli.Run([]string{"pull", "--all"}, s.stdout, s.stderr)
|
||||||
|
|
||||||
|
|||||||
@@ -77,3 +77,13 @@ func (s *ExecSuite) TestExecAll_RunsCommandForEachCastle() {
|
|||||||
require.NoError(s.T(), s.app.ExecAll([]string{"basename \"$PWD\""}))
|
require.NoError(s.T(), s.app.ExecAll([]string{"basename \"$PWD\""}))
|
||||||
require.Equal(s.T(), "alpha\nzeta\n", s.stdout.String())
|
require.Equal(s.T(), "alpha\nzeta\n", s.stdout.String())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (s *ExecSuite) TestExec_PretendDoesNotExecuteCommand() {
|
||||||
|
castleRoot := s.createCastle("dotfiles")
|
||||||
|
target := filepath.Join(castleRoot, "should-not-exist")
|
||||||
|
|
||||||
|
s.app.Pretend = true
|
||||||
|
require.NoError(s.T(), s.app.Exec("dotfiles", []string{"touch should-not-exist"}))
|
||||||
|
require.NoFileExists(s.T(), target)
|
||||||
|
require.Contains(s.T(), s.stdout.String(), "Would execute")
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user