1
0
mirror of https://github.com/jesseduffield/lazygit.git synced 2025-06-17 00:18:05 +02:00

fix issue #640 add catCmd and OS-specific values

Add a catCmd to the Platform struct and set the value to "cat" for
non-windows builds and "type" for windows builds.
This commit is contained in:
Tyler Davis
2020-04-25 03:32:59 +00:00
committed by Jesse Duffield
parent 42d21c4bb6
commit b5404c6159
5 changed files with 14 additions and 3 deletions

View File

@ -6,6 +6,7 @@ import (
"os"
"os/exec"
"regexp"
"runtime"
"testing"
"time"
@ -1022,11 +1023,18 @@ func TestGitCommandPush(t *testing.T) {
}
}
// TestGitCommandCatFile is a function.
// TestGitCommandCatFile tests emitting a file using commands, where commands vary by OS.
func TestGitCommandCatFile(t *testing.T) {
var osCmd string
switch os := runtime.GOOS; os {
case "windows":
osCmd = "type"
default:
osCmd = "cat"
}
gitCmd := NewDummyGitCommand()
gitCmd.OSCommand.command = func(cmd string, args ...string) *exec.Cmd {
assert.EqualValues(t, "cat", cmd)
assert.EqualValues(t, osCmd, cmd)
assert.EqualValues(t, []string{"test.txt"}, args)
return exec.Command("echo", "-n", "test")