test(parity): add behavior suite regression coverage
This commit is contained in:
@@ -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)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user