summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--pkg/commands/git_test.go17
-rw-r--r--pkg/commands/os_test.go22
2 files changed, 17 insertions, 22 deletions
diff --git a/pkg/commands/git_test.go b/pkg/commands/git_test.go
index c930f76eb..0d076254a 100644
--- a/pkg/commands/git_test.go
+++ b/pkg/commands/git_test.go
@@ -9,28 +9,21 @@ import (
"github.com/jesseduffield/lazygit/pkg/test"
)
-func getDummyLog() *logrus.Logger {
+func newDummyLog() *logrus.Logger {
log := logrus.New()
log.Out = ioutil.Discard
return log
}
-func getDummyOSCommand() *OSCommand {
- return &OSCommand{
- Log: getDummyLog(),
- Platform: getPlatform(),
- }
-}
-
-func getDummyGitCommand() *GitCommand {
+func newDummyGitCommand() *GitCommand {
return &GitCommand{
- Log: getDummyLog(),
- OSCommand: getDummyOSCommand(),
+ Log: newDummyLog(),
+ OSCommand: newDummyOSCommand(),
}
}
func TestDiff(t *testing.T) {
- gitCommand := getDummyGitCommand()
+ gitCommand := newDummyGitCommand()
if err := test.GenerateRepo("lots_of_diffs.sh"); err != nil {
t.Error(err.Error())
}
diff --git a/pkg/commands/os_test.go b/pkg/commands/os_test.go
index 128caa1b2..9d5cc1354 100644
--- a/pkg/commands/os_test.go
+++ b/pkg/commands/os_test.go
@@ -3,12 +3,14 @@ package commands
import (
"testing"
- "github.com/Sirupsen/logrus"
-
"github.com/stretchr/testify/assert"
)
-func TestRunCommandWithOutput(t *testing.T) {
+func newDummyOSCommand() *OSCommand {
+ return NewOSCommand(newDummyLog())
+}
+
+func TestOSCommandRunCommandWithOutput(t *testing.T) {
type scenario struct {
command string
test func(string, error)
@@ -31,11 +33,11 @@ func TestRunCommandWithOutput(t *testing.T) {
}
for _, s := range scenarios {
- s.test(NewOSCommand(logrus.New()).RunCommandWithOutput(s.command))
+ s.test(newDummyOSCommand().RunCommandWithOutput(s.command))
}
}
-func TestRunCommand(t *testing.T) {
+func TestOSCommandRunCommand(t *testing.T) {
type scenario struct {
command string
test func(error)
@@ -51,12 +53,12 @@ func TestRunCommand(t *testing.T) {
}
for _, s := range scenarios {
- s.test(NewOSCommand(logrus.New()).RunCommand(s.command))
+ s.test(newDummyOSCommand().RunCommand(s.command))
}
}
-func TestQuote(t *testing.T) {
- osCommand := NewOSCommand(logrus.New())
+func TestOSCommandQuote(t *testing.T) {
+ osCommand := newDummyOSCommand()
actual := osCommand.Quote("hello `test`")
@@ -65,8 +67,8 @@ func TestQuote(t *testing.T) {
assert.EqualValues(t, expected, actual)
}
-func TestUnquote(t *testing.T) {
- osCommand := NewOSCommand(logrus.New())
+func TestOSCommandUnquote(t *testing.T) {
+ osCommand := newDummyOSCommand()
actual := osCommand.Unquote(`hello "test"`)