mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-03-05 15:15:49 +02:00
move dummy functions, rename functions
This commit is contained in:
parent
f91e2b12db
commit
38f11f1f4a
@ -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())
|
||||
}
|
||||
|
@ -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"`)
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user