1
0
mirror of https://github.com/jesseduffield/lazygit.git synced 2025-05-31 23:19:40 +02:00

move dummy functions, rename functions

This commit is contained in:
Anthony HAMON 2018-08-22 22:30:02 +02:00
parent f91e2b12db
commit 38f11f1f4a
2 changed files with 17 additions and 22 deletions

View File

@ -9,28 +9,21 @@ import (
"github.com/jesseduffield/lazygit/pkg/test" "github.com/jesseduffield/lazygit/pkg/test"
) )
func getDummyLog() *logrus.Logger { func newDummyLog() *logrus.Logger {
log := logrus.New() log := logrus.New()
log.Out = ioutil.Discard log.Out = ioutil.Discard
return log return log
} }
func getDummyOSCommand() *OSCommand { func newDummyGitCommand() *GitCommand {
return &OSCommand{
Log: getDummyLog(),
Platform: getPlatform(),
}
}
func getDummyGitCommand() *GitCommand {
return &GitCommand{ return &GitCommand{
Log: getDummyLog(), Log: newDummyLog(),
OSCommand: getDummyOSCommand(), OSCommand: newDummyOSCommand(),
} }
} }
func TestDiff(t *testing.T) { func TestDiff(t *testing.T) {
gitCommand := getDummyGitCommand() gitCommand := newDummyGitCommand()
if err := test.GenerateRepo("lots_of_diffs.sh"); err != nil { if err := test.GenerateRepo("lots_of_diffs.sh"); err != nil {
t.Error(err.Error()) t.Error(err.Error())
} }

View File

@ -3,12 +3,14 @@ package commands
import ( import (
"testing" "testing"
"github.com/Sirupsen/logrus"
"github.com/stretchr/testify/assert" "github.com/stretchr/testify/assert"
) )
func TestRunCommandWithOutput(t *testing.T) { func newDummyOSCommand() *OSCommand {
return NewOSCommand(newDummyLog())
}
func TestOSCommandRunCommandWithOutput(t *testing.T) {
type scenario struct { type scenario struct {
command string command string
test func(string, error) test func(string, error)
@ -31,11 +33,11 @@ func TestRunCommandWithOutput(t *testing.T) {
} }
for _, s := range scenarios { 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 { type scenario struct {
command string command string
test func(error) test func(error)
@ -51,12 +53,12 @@ func TestRunCommand(t *testing.T) {
} }
for _, s := range scenarios { for _, s := range scenarios {
s.test(NewOSCommand(logrus.New()).RunCommand(s.command)) s.test(newDummyOSCommand().RunCommand(s.command))
} }
} }
func TestQuote(t *testing.T) { func TestOSCommandQuote(t *testing.T) {
osCommand := NewOSCommand(logrus.New()) osCommand := newDummyOSCommand()
actual := osCommand.Quote("hello `test`") actual := osCommand.Quote("hello `test`")
@ -65,8 +67,8 @@ func TestQuote(t *testing.T) {
assert.EqualValues(t, expected, actual) assert.EqualValues(t, expected, actual)
} }
func TestUnquote(t *testing.T) { func TestOSCommandUnquote(t *testing.T) {
osCommand := NewOSCommand(logrus.New()) osCommand := newDummyOSCommand()
actual := osCommand.Unquote(`hello "test"`) actual := osCommand.Unquote(`hello "test"`)