summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJasper Mendiola <jasperduane77@gmail.com>2020-07-10 16:42:55 +0800
committerJesse Duffield <jessedduffield@gmail.com>2020-07-10 18:55:00 +1000
commitcb0bdd89c0b81cd91e9f1869af82f5b7151c2b58 (patch)
tree8b689a716362eece14eb37f8937508743e7fa320
parente89bf5d06b8a90b0aca702c0b9ef570504183cd1 (diff)
fix tests
-rw-r--r--pkg/commands/dummies.go8
-rw-r--r--pkg/commands/git_test.go11
2 files changed, 13 insertions, 6 deletions
diff --git a/pkg/commands/dummies.go b/pkg/commands/dummies.go
index 34bf549d3..166fa4c8c 100644
--- a/pkg/commands/dummies.go
+++ b/pkg/commands/dummies.go
@@ -7,6 +7,7 @@ import (
"github.com/jesseduffield/lazygit/pkg/i18n"
"github.com/sirupsen/logrus"
"github.com/spf13/viper"
+ appconfig "github.com/jesseduffield/lazygit/pkg/config"
yaml "gopkg.in/yaml.v2"
)
@@ -19,6 +20,11 @@ func NewDummyOSCommand() *OSCommand {
// NewDummyAppConfig creates a new dummy AppConfig for testing
func NewDummyAppConfig() *config.AppConfig {
+ userConfig := viper.New()
+ userConfig.SetConfigType("yaml")
+ if err := appconfig.LoadDefaults(userConfig, appconfig.GetDefaultConfig()); err != nil {
+ panic(err)
+ }
appConfig := &config.AppConfig{
Name: "lazygit",
Version: "unversioned",
@@ -26,7 +32,7 @@ func NewDummyAppConfig() *config.AppConfig {
BuildDate: "",
Debug: false,
BuildSource: "",
- UserConfig: viper.New(),
+ UserConfig: userConfig,
}
_ = yaml.Unmarshal([]byte{}, appConfig.AppState)
return appConfig
diff --git a/pkg/commands/git_test.go b/pkg/commands/git_test.go
index b70947534..8d56dee40 100644
--- a/pkg/commands/git_test.go
+++ b/pkg/commands/git_test.go
@@ -1384,13 +1384,14 @@ func TestGitCommandCheckout(t *testing.T) {
// TestGitCommandGetBranchGraph is a function.
func TestGitCommandGetBranchGraph(t *testing.T) {
gitCmd := NewDummyGitCommand()
+ gitCmd.getLocalGitConfig = func(string) (string, error) {
+ return "git log --graph --color=always --abbrev-commit --decorate --date=relative --pretty=medium {{branchName}} --", nil
+ }
gitCmd.OSCommand.command = func(cmd string, args ...string) *exec.Cmd {
assert.EqualValues(t, "git", cmd)
assert.EqualValues(t, []string{"log", "--graph", "--color=always", "--abbrev-commit", "--decorate", "--date=relative", "--pretty=medium", "test", "--"}, args)
-
return exec.Command("echo")
}
-
_, err := gitCmd.GetBranchGraph("test")
assert.NoError(t, err)
}
@@ -1410,7 +1411,7 @@ func TestGitCommandDiff(t *testing.T) {
"Default case",
func(cmd string, args ...string) *exec.Cmd {
assert.EqualValues(t, "git", cmd)
- assert.EqualValues(t, []string{"diff", "--color=", "--", "test.txt"}, args)
+ assert.EqualValues(t, []string{"diff", "--color=always", "--", "test.txt"}, args)
return exec.Command("echo")
},
@@ -1426,7 +1427,7 @@ func TestGitCommandDiff(t *testing.T) {
"cached",
func(cmd string, args ...string) *exec.Cmd {
assert.EqualValues(t, "git", cmd)
- assert.EqualValues(t, []string{"diff", "--color=", "--cached", "--", "test.txt"}, args)
+ assert.EqualValues(t, []string{"diff", "--color=always", "--cached", "--", "test.txt"}, args)
return exec.Command("echo")
},
@@ -1458,7 +1459,7 @@ func TestGitCommandDiff(t *testing.T) {
"File not tracked and file has no staged changes",
func(cmd string, args ...string) *exec.Cmd {
assert.EqualValues(t, "git", cmd)
- assert.EqualValues(t, []string{"diff", "--color=", "--no-index", "/dev/null", "test.txt"}, args)
+ assert.EqualValues(t, []string{"diff", "--color=always", "--no-index", "/dev/null", "test.txt"}, args)
return exec.Command("echo")
},