gosick #1
@@ -167,3 +167,27 @@ func (s *CLISuite) TestRun_Help_UsesProgramNameAndDescription() {
|
|||||||
require.Contains(s.T(), s.stdout.String(), "precious dotfiles")
|
require.Contains(s.T(), s.stdout.String(), "precious dotfiles")
|
||||||
require.Empty(s.T(), s.stderr.String())
|
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())
|
||||||
|
}
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import (
|
|||||||
"io"
|
"io"
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
"strings"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"git.hrafn.xyz/aether/gosick/internal/homesick/core"
|
"git.hrafn.xyz/aether/gosick/internal/homesick/core"
|
||||||
@@ -33,6 +34,7 @@ func (s *DestroySuite) SetupTest() {
|
|||||||
s.app = &core.App{
|
s.app = &core.App{
|
||||||
HomeDir: s.homeDir,
|
HomeDir: s.homeDir,
|
||||||
ReposDir: s.reposDir,
|
ReposDir: s.reposDir,
|
||||||
|
Stdin: strings.NewReader("y\n"),
|
||||||
Stdout: io.Discard,
|
Stdout: io.Discard,
|
||||||
Stderr: io.Discard,
|
Stderr: io.Discard,
|
||||||
}
|
}
|
||||||
@@ -50,6 +52,7 @@ func (s *DestroySuite) TestDestroy_RemovesCastleDirectory() {
|
|||||||
castleRoot := s.createCastleRepo("dotfiles")
|
castleRoot := s.createCastleRepo("dotfiles")
|
||||||
require.DirExists(s.T(), castleRoot)
|
require.DirExists(s.T(), castleRoot)
|
||||||
|
|
||||||
|
s.app.Stdin = strings.NewReader("y\n")
|
||||||
require.NoError(s.T(), s.app.Destroy("dotfiles"))
|
require.NoError(s.T(), s.app.Destroy("dotfiles"))
|
||||||
require.NoDirExists(s.T(), castleRoot)
|
require.NoDirExists(s.T(), castleRoot)
|
||||||
}
|
}
|
||||||
@@ -70,6 +73,7 @@ func (s *DestroySuite) TestDestroy_UnlinksDotfilesBeforeRemoval() {
|
|||||||
require.NoError(s.T(), err)
|
require.NoError(s.T(), err)
|
||||||
require.NotZero(s.T(), info.Mode()&os.ModeSymlink)
|
require.NotZero(s.T(), info.Mode()&os.ModeSymlink)
|
||||||
|
|
||||||
|
s.app.Stdin = strings.NewReader("y\n")
|
||||||
require.NoError(s.T(), s.app.Destroy("dotfiles"))
|
require.NoError(s.T(), s.app.Destroy("dotfiles"))
|
||||||
|
|
||||||
_, err = os.Lstat(homePath)
|
_, err = os.Lstat(homePath)
|
||||||
@@ -85,7 +89,17 @@ func (s *DestroySuite) TestDestroy_RemovesSymlinkedCastleOnly() {
|
|||||||
symlinkCastle := filepath.Join(s.reposDir, "dotfiles")
|
symlinkCastle := filepath.Join(s.reposDir, "dotfiles")
|
||||||
require.NoError(s.T(), os.Symlink(target, symlinkCastle))
|
require.NoError(s.T(), os.Symlink(target, symlinkCastle))
|
||||||
|
|
||||||
|
s.app.Stdin = strings.NewReader("y\n")
|
||||||
require.NoError(s.T(), s.app.Destroy("dotfiles"))
|
require.NoError(s.T(), s.app.Destroy("dotfiles"))
|
||||||
require.NoFileExists(s.T(), symlinkCastle)
|
require.NoFileExists(s.T(), symlinkCastle)
|
||||||
require.DirExists(s.T(), target)
|
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)
|
||||||
|
}
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package core_test
|
package core_test
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"bytes"
|
||||||
"io"
|
"io"
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
@@ -127,3 +128,15 @@ func (s *PullSuite) TestPullAll_UpdatesAllCastlesFromOrigin() {
|
|||||||
func (s *PullSuite) TestPullAll_NoCastlesIsNoop() {
|
func (s *PullSuite) TestPullAll_NoCastlesIsNoop() {
|
||||||
require.NoError(s.T(), s.app.PullAll())
|
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:")
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user