From abfd6b817b33270bbb9ce064760e242d26cf1c1a Mon Sep 17 00:00:00 2001 From: Micheal Wilkinson Date: Sat, 21 Mar 2026 10:58:08 +0000 Subject: [PATCH] test(parity): add behavior suite regression coverage --- internal/homesick/cli/cli_test.go | 24 ++++++++++++++++++++++++ internal/homesick/core/destroy_test.go | 14 ++++++++++++++ internal/homesick/core/pull_test.go | 13 +++++++++++++ 3 files changed, 51 insertions(+) diff --git a/internal/homesick/cli/cli_test.go b/internal/homesick/cli/cli_test.go index e20368d..ba40dfa 100644 --- a/internal/homesick/cli/cli_test.go +++ b/internal/homesick/cli/cli_test.go @@ -167,3 +167,27 @@ func (s *CLISuite) TestRun_Help_UsesProgramNameAndDescription() { require.Contains(s.T(), s.stdout.String(), "precious dotfiles") require.Empty(s.T(), s.stderr.String()) } + +func (s *CLISuite) TestRun_SymlinkAlias_MatchesLinkCommand() { + castleRoot := filepath.Join(s.homeDir, ".homesick", "repos", "dotfiles") + castleHome := filepath.Join(castleRoot, "home") + require.NoError(s.T(), os.MkdirAll(castleHome, 0o755)) + require.NoError(s.T(), os.WriteFile(filepath.Join(castleHome, ".vimrc"), []byte("set number\n"), 0o644)) + + exitCode := cli.Run([]string{"symlink", "dotfiles"}, s.stdout, s.stderr) + + require.Equal(s.T(), 0, exitCode) + target := filepath.Join(s.homeDir, ".vimrc") + info, err := os.Lstat(target) + require.NoError(s.T(), err) + require.True(s.T(), info.Mode()&os.ModeSymlink != 0) + require.Empty(s.T(), s.stderr.String()) +} + +func (s *CLISuite) TestRun_Commit_PositionalMessageCompatibility() { + exitCode := cli.Run([]string{"--pretend", "commit", "dotfiles", "behavior-suite-commit"}, s.stdout, s.stderr) + + require.Equal(s.T(), 0, exitCode) + require.Contains(s.T(), s.stdout.String(), "git commit -m behavior-suite-commit") + require.Empty(s.T(), s.stderr.String()) +} diff --git a/internal/homesick/core/destroy_test.go b/internal/homesick/core/destroy_test.go index fe4400b..07af744 100644 --- a/internal/homesick/core/destroy_test.go +++ b/internal/homesick/core/destroy_test.go @@ -4,6 +4,7 @@ import ( "io" "os" "path/filepath" + "strings" "testing" "git.hrafn.xyz/aether/gosick/internal/homesick/core" @@ -33,6 +34,7 @@ func (s *DestroySuite) SetupTest() { s.app = &core.App{ HomeDir: s.homeDir, ReposDir: s.reposDir, + Stdin: strings.NewReader("y\n"), Stdout: io.Discard, Stderr: io.Discard, } @@ -50,6 +52,7 @@ func (s *DestroySuite) TestDestroy_RemovesCastleDirectory() { castleRoot := s.createCastleRepo("dotfiles") require.DirExists(s.T(), castleRoot) + s.app.Stdin = strings.NewReader("y\n") require.NoError(s.T(), s.app.Destroy("dotfiles")) require.NoDirExists(s.T(), castleRoot) } @@ -70,6 +73,7 @@ func (s *DestroySuite) TestDestroy_UnlinksDotfilesBeforeRemoval() { require.NoError(s.T(), err) require.NotZero(s.T(), info.Mode()&os.ModeSymlink) + s.app.Stdin = strings.NewReader("y\n") require.NoError(s.T(), s.app.Destroy("dotfiles")) _, err = os.Lstat(homePath) @@ -85,7 +89,17 @@ func (s *DestroySuite) TestDestroy_RemovesSymlinkedCastleOnly() { symlinkCastle := filepath.Join(s.reposDir, "dotfiles") require.NoError(s.T(), os.Symlink(target, symlinkCastle)) + s.app.Stdin = strings.NewReader("y\n") require.NoError(s.T(), s.app.Destroy("dotfiles")) require.NoFileExists(s.T(), symlinkCastle) require.DirExists(s.T(), target) } + +func (s *DestroySuite) TestDestroy_DeclineConfirmationKeepsCastle() { + castleRoot := s.createCastleRepo("dotfiles") + require.DirExists(s.T(), castleRoot) + + s.app.Stdin = strings.NewReader("n\n") + require.NoError(s.T(), s.app.Destroy("dotfiles")) + require.DirExists(s.T(), castleRoot) +} diff --git a/internal/homesick/core/pull_test.go b/internal/homesick/core/pull_test.go index 87f2fd1..eacd224 100644 --- a/internal/homesick/core/pull_test.go +++ b/internal/homesick/core/pull_test.go @@ -1,6 +1,7 @@ package core_test import ( + "bytes" "io" "os" "path/filepath" @@ -127,3 +128,15 @@ func (s *PullSuite) TestPullAll_UpdatesAllCastlesFromOrigin() { func (s *PullSuite) TestPullAll_NoCastlesIsNoop() { require.NoError(s.T(), s.app.PullAll()) } + +func (s *PullSuite) TestPullAll_PrintsCastlePrefixes() { + _, _ = s.createRemoteWithClone("alpha") + _, _ = s.createRemoteWithClone("zeta") + + stdout := &bytes.Buffer{} + s.app.Stdout = stdout + + require.NoError(s.T(), s.app.PullAll()) + require.Contains(s.T(), stdout.String(), "alpha:") + require.Contains(s.T(), stdout.String(), "zeta:") +}