chore(go): inject stdin and pass rc force explicitly
This commit is contained in:
@@ -53,7 +53,7 @@ var _ io.Writer
|
||||
// TestRc_UnknownCastleReturnsError ensures Rc returns an error when the
|
||||
// castle directory does not exist.
|
||||
func (s *RcSuite) TestRc_UnknownCastleReturnsError() {
|
||||
err := s.app.Rc("nonexistent")
|
||||
err := s.app.Rc("nonexistent", false)
|
||||
require.Error(s.T(), err)
|
||||
}
|
||||
|
||||
@@ -61,7 +61,7 @@ func (s *RcSuite) TestRc_UnknownCastleReturnsError() {
|
||||
// .homesickrc are present.
|
||||
func (s *RcSuite) TestRc_NoScriptsAndNoHomesickrcIsNoop() {
|
||||
s.createCastle("dotfiles")
|
||||
require.NoError(s.T(), s.app.Rc("dotfiles"))
|
||||
require.NoError(s.T(), s.app.Rc("dotfiles", false))
|
||||
}
|
||||
|
||||
// TestRc_HomesickrcRequiresForce ensures legacy .homesickrc does not run
|
||||
@@ -71,7 +71,7 @@ func (s *RcSuite) TestRc_HomesickrcRequiresForce() {
|
||||
homesickRc := filepath.Join(castleRoot, ".homesickrc")
|
||||
require.NoError(s.T(), os.WriteFile(homesickRc, []byte("# ruby setup code\n"), 0o644))
|
||||
|
||||
err := s.app.Rc("dotfiles")
|
||||
err := s.app.Rc("dotfiles", false)
|
||||
require.Error(s.T(), err)
|
||||
require.Contains(s.T(), err.Error(), "--force")
|
||||
require.NoFileExists(s.T(), filepath.Join(castleRoot, ".homesick.d", "parity.rb"))
|
||||
@@ -84,8 +84,7 @@ func (s *RcSuite) TestRc_HomesickrcRunsWithForce() {
|
||||
homesickRc := filepath.Join(castleRoot, ".homesickrc")
|
||||
require.NoError(s.T(), os.WriteFile(homesickRc, []byte("# ruby setup code\n"), 0o644))
|
||||
|
||||
s.app.Force = true
|
||||
require.NoError(s.T(), s.app.Rc("dotfiles"))
|
||||
require.NoError(s.T(), s.app.Rc("dotfiles", true))
|
||||
require.FileExists(s.T(), filepath.Join(castleRoot, ".homesick.d", "parity.rb"))
|
||||
}
|
||||
|
||||
@@ -103,7 +102,7 @@ func (s *RcSuite) TestRc_ExecutesScriptsInSortedOrder() {
|
||||
require.NoError(s.T(), os.WriteFile(scriptA, []byte("#!/bin/sh\necho a >> "+orderFile+"\n"), 0o755))
|
||||
require.NoError(s.T(), os.WriteFile(scriptB, []byte("#!/bin/sh\necho b >> "+orderFile+"\n"), 0o755))
|
||||
|
||||
require.NoError(s.T(), s.app.Rc("dotfiles"))
|
||||
require.NoError(s.T(), s.app.Rc("dotfiles", false))
|
||||
|
||||
content, err := os.ReadFile(orderFile)
|
||||
require.NoError(s.T(), err)
|
||||
@@ -121,7 +120,7 @@ func (s *RcSuite) TestRc_SkipsNonExecutableFiles() {
|
||||
// Write a script that would exit 1 if actually run — verify it is skipped.
|
||||
require.NoError(s.T(), os.WriteFile(notExec, []byte("#!/bin/sh\nexit 1\n"), 0o644))
|
||||
|
||||
require.NoError(s.T(), s.app.Rc("dotfiles"))
|
||||
require.NoError(s.T(), s.app.Rc("dotfiles", false))
|
||||
}
|
||||
|
||||
// TestRc_HomesickrcCreatesRubyWrapper verifies that a .homesickrc file causes
|
||||
@@ -130,9 +129,7 @@ func (s *RcSuite) TestRc_HomesickrcCreatesRubyWrapper() {
|
||||
castleRoot := s.createCastle("dotfiles")
|
||||
homesickRc := filepath.Join(castleRoot, ".homesickrc")
|
||||
require.NoError(s.T(), os.WriteFile(homesickRc, []byte("# ruby setup code\n"), 0o644))
|
||||
s.app.Force = true
|
||||
|
||||
require.NoError(s.T(), s.app.Rc("dotfiles"))
|
||||
require.NoError(s.T(), s.app.Rc("dotfiles", true))
|
||||
|
||||
wrapperPath := filepath.Join(castleRoot, ".homesick.d", "parity.rb")
|
||||
require.FileExists(s.T(), wrapperPath)
|
||||
@@ -152,7 +149,6 @@ func (s *RcSuite) TestRc_HomesickrcWrapperNotOverwrittenIfExists() {
|
||||
castleRoot := s.createCastle("dotfiles")
|
||||
homesickRc := filepath.Join(castleRoot, ".homesickrc")
|
||||
require.NoError(s.T(), os.WriteFile(homesickRc, []byte("# ruby setup code\n"), 0o644))
|
||||
s.app.Force = true
|
||||
|
||||
homesickD := filepath.Join(castleRoot, ".homesick.d")
|
||||
require.NoError(s.T(), os.MkdirAll(homesickD, 0o755))
|
||||
@@ -160,7 +156,7 @@ func (s *RcSuite) TestRc_HomesickrcWrapperNotOverwrittenIfExists() {
|
||||
originalContent := []byte("#!/bin/sh\n# pre-existing wrapper\n")
|
||||
require.NoError(s.T(), os.WriteFile(wrapperPath, originalContent, 0o755))
|
||||
|
||||
require.NoError(s.T(), s.app.Rc("dotfiles"))
|
||||
require.NoError(s.T(), s.app.Rc("dotfiles", true))
|
||||
|
||||
content, err := os.ReadFile(wrapperPath)
|
||||
require.NoError(s.T(), err)
|
||||
@@ -173,7 +169,6 @@ func (s *RcSuite) TestRc_HomesickrcWrapperCreatedBeforeExecution() {
|
||||
castleRoot := s.createCastle("dotfiles")
|
||||
homesickRc := filepath.Join(castleRoot, ".homesickrc")
|
||||
require.NoError(s.T(), os.WriteFile(homesickRc, []byte("# ruby setup code\n"), 0o644))
|
||||
s.app.Force = true
|
||||
|
||||
homesickD := filepath.Join(castleRoot, ".homesick.d")
|
||||
require.NoError(s.T(), os.MkdirAll(homesickD, 0o755))
|
||||
@@ -186,7 +181,7 @@ func (s *RcSuite) TestRc_HomesickrcWrapperCreatedBeforeExecution() {
|
||||
"#!/bin/sh\n[ -f "+wrapperPath+" ] && echo present >> "+orderFile+"\n",
|
||||
), 0o755))
|
||||
|
||||
require.NoError(s.T(), s.app.Rc("dotfiles"))
|
||||
require.NoError(s.T(), s.app.Rc("dotfiles", true))
|
||||
|
||||
content, err := os.ReadFile(orderFile)
|
||||
require.NoError(s.T(), err)
|
||||
@@ -203,7 +198,7 @@ func (s *RcSuite) TestRc_FailingScriptReturnsError() {
|
||||
failing := filepath.Join(homesickD, "10_fail.sh")
|
||||
require.NoError(s.T(), os.WriteFile(failing, []byte("#!/bin/sh\nexit 42\n"), 0o755))
|
||||
|
||||
err := s.app.Rc("dotfiles")
|
||||
err := s.app.Rc("dotfiles", false)
|
||||
require.Error(s.T(), err)
|
||||
}
|
||||
|
||||
@@ -217,7 +212,7 @@ func (s *RcSuite) TestRc_ScriptOutputForwarded() {
|
||||
script := filepath.Join(homesickD, "10_output.sh")
|
||||
require.NoError(s.T(), os.WriteFile(script, []byte("#!/bin/sh\necho hello\necho world >&2\n"), 0o755))
|
||||
|
||||
require.NoError(s.T(), s.app.Rc("dotfiles"))
|
||||
require.NoError(s.T(), s.app.Rc("dotfiles", false))
|
||||
require.Contains(s.T(), s.stdout.String(), "hello")
|
||||
require.Contains(s.T(), s.stderr.String(), "world")
|
||||
}
|
||||
@@ -232,6 +227,6 @@ func (s *RcSuite) TestRc_ScriptsRunWithCwdSetToCastleRoot() {
|
||||
script := filepath.Join(homesickD, "10_pwd.sh")
|
||||
require.NoError(s.T(), os.WriteFile(script, []byte("#!/bin/sh\npwd\n"), 0o755))
|
||||
|
||||
require.NoError(s.T(), s.app.Rc("dotfiles"))
|
||||
require.NoError(s.T(), s.app.Rc("dotfiles", false))
|
||||
require.Contains(s.T(), s.stdout.String(), castleRoot)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user