diff options
author | Jesse Duffield <jessedduffield@gmail.com> | 2022-02-26 15:02:28 +1100 |
---|---|---|
committer | Jesse Duffield <jessedduffield@gmail.com> | 2022-03-17 19:13:40 +1100 |
commit | 3e26f39deed48dbe133e076ab7ab7fffded52cf4 (patch) | |
tree | 3d9b2ad402168bed4e2faa1b899a2a9c947180d7 /pkg | |
parent | ef7c4c9ca93ec15db4886d8d6f78c85a1db7edef (diff) |
remove dead code
Diffstat (limited to 'pkg')
-rw-r--r-- | pkg/test/test.go | 32 | ||||
-rw-r--r-- | pkg/test/utils.go | 59 |
2 files changed, 0 insertions, 91 deletions
diff --git a/pkg/test/test.go b/pkg/test/test.go deleted file mode 100644 index da476b95c..000000000 --- a/pkg/test/test.go +++ /dev/null @@ -1,32 +0,0 @@ -package test - -import ( - "os" - "path/filepath" - - "github.com/go-errors/errors" - - "github.com/jesseduffield/lazygit/pkg/secureexec" - "github.com/jesseduffield/lazygit/pkg/utils" -) - -// GenerateRepo generates a repo from test/repos and changes the directory to be -// inside the newly made repo -func GenerateRepo(filename string) error { - reposDir := "/test/repos/" - testPath := utils.GetProjectRoot() + reposDir - - // workaround for debian packaging - if _, err := os.Stat(testPath); os.IsNotExist(err) { - cwd, _ := os.Getwd() - testPath = filepath.Dir(filepath.Dir(cwd)) + reposDir - } - if err := os.Chdir(testPath); err != nil { - return err - } - if output, err := secureexec.Command("bash", filename).CombinedOutput(); err != nil { - return errors.New(string(output)) - } - - return os.Chdir(testPath + "repo") -} diff --git a/pkg/test/utils.go b/pkg/test/utils.go deleted file mode 100644 index 47f2c1146..000000000 --- a/pkg/test/utils.go +++ /dev/null @@ -1,59 +0,0 @@ -package test - -import ( - "fmt" - "os/exec" - "regexp" - "strings" - "testing" - - "github.com/jesseduffield/lazygit/pkg/secureexec" - "github.com/mgutz/str" - "github.com/stretchr/testify/assert" -) - -// CommandSwapper takes a command, verifies that it is what it's expected to be -// and then returns a replacement command that will actually be called by the os -type CommandSwapper struct { - Expect string - Replace string -} - -// SwapCommand verifies the command is what we expected, and swaps it out for a different command -func (i *CommandSwapper) SwapCommand(t *testing.T, cmd string, args []string) *exec.Cmd { - splitCmd := str.ToArgv(i.Expect) - assert.EqualValues(t, splitCmd[0], cmd, fmt.Sprintf("received command: %s %s", cmd, strings.Join(args, " "))) - if len(splitCmd) > 1 { - assert.EqualValues(t, splitCmd[1:], args, fmt.Sprintf("received command: %s %s", cmd, strings.Join(args, " "))) - } - - splitCmd = str.ToArgv(i.Replace) - return secureexec.Command(splitCmd[0], splitCmd[1:]...) -} - -// CreateMockCommand creates a command function that will verify its receiving the right sequence of commands from lazygit -func CreateMockCommand(t *testing.T, swappers []*CommandSwapper) func(cmd string, args ...string) *exec.Cmd { - commandIndex := 0 - - return func(cmd string, args ...string) *exec.Cmd { - var command *exec.Cmd - if commandIndex > len(swappers)-1 { - assert.Fail(t, fmt.Sprintf("too many commands run. This command was (%s %s)", cmd, strings.Join(args, " "))) - } - command = swappers[commandIndex].SwapCommand(t, cmd, args) - commandIndex++ - return command - } -} - -func AssertContainsMatch(t *testing.T, strs []string, pattern *regexp.Regexp, message string) { - t.Helper() - - for _, str := range strs { - if pattern.Match([]byte(str)) { - return - } - } - - assert.Fail(t, message) -} |