diff options
author | Anthony HAMON <anthony.hamon@iadvize.com> | 2018-08-22 22:30:02 +0200 |
---|---|---|
committer | Anthony HAMON <anthony.hamon@iadvize.com> | 2018-08-26 01:58:19 +0200 |
commit | 38f11f1f4a9df758a7ff030247a171711dca2339 (patch) | |
tree | 538e7ed8e7516ed3af323f0bde0ea69870e1951d /pkg | |
parent | f91e2b12dbc02e3dc05f5ae746d16a702ba57c27 (diff) |
move dummy functions, rename functions
Diffstat (limited to 'pkg')
-rw-r--r-- | pkg/commands/git_test.go | 17 | ||||
-rw-r--r-- | pkg/commands/os_test.go | 22 |
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"`) |