1
0
mirror of https://github.com/jesseduffield/lazygit.git synced 2024-12-04 10:34:55 +02:00
This commit is contained in:
Jesse Duffield 2022-01-08 15:46:29 +11:00
parent e4e521f58a
commit 5d6d894286

View File

@ -1,6 +1,8 @@
package git_config package git_config
import ( import (
"os/exec"
"strings"
"testing" "testing"
"github.com/jesseduffield/lazygit/pkg/utils" "github.com/jesseduffield/lazygit/pkg/utils"
@ -52,8 +54,9 @@ func TestGetBool(t *testing.T) {
t.Run(s.testName, func(t *testing.T) { t.Run(s.testName, func(t *testing.T) {
fake := NewFakeGitConfig(s.mockResponses) fake := NewFakeGitConfig(s.mockResponses)
real := NewCachedGitConfig( real := NewCachedGitConfig(
func(key string) (string, error) { func(cmd *exec.Cmd) (string, error) {
return fake.Get(key), nil assert.Equal(t, "git config --get --null commit.gpgsign", strings.Join(cmd.Args, " "))
return fake.Get("commit.gpgsign"), nil
}, },
utils.NewDummyLog(), utils.NewDummyLog(),
) )
@ -88,8 +91,9 @@ func TestGet(t *testing.T) {
t.Run(s.testName, func(t *testing.T) { t.Run(s.testName, func(t *testing.T) {
fake := NewFakeGitConfig(s.mockResponses) fake := NewFakeGitConfig(s.mockResponses)
real := NewCachedGitConfig( real := NewCachedGitConfig(
func(key string) (string, error) { func(cmd *exec.Cmd) (string, error) {
return fake.Get(key), nil assert.Equal(t, "git config --get --null commit.gpgsign", strings.Join(cmd.Args, " "))
return fake.Get("commit.gpgsign"), nil
}, },
utils.NewDummyLog(), utils.NewDummyLog(),
) )
@ -101,9 +105,9 @@ func TestGet(t *testing.T) {
// verifying that the cache is used // verifying that the cache is used
count := 0 count := 0
real := NewCachedGitConfig( real := NewCachedGitConfig(
func(key string) (string, error) { func(cmd *exec.Cmd) (string, error) {
count++ count++
assert.Equal(t, "commit.gpgsign", key) assert.Equal(t, "git config --get --null commit.gpgsign", strings.Join(cmd.Args, " "))
return "blah", nil return "blah", nil
}, },
utils.NewDummyLog(), utils.NewDummyLog(),