From 533f222950605de97e6a19aa888e83fe3b689dbe Mon Sep 17 00:00:00 2001 From: Carlos Alexandro Becker Date: Wed, 24 May 2023 16:54:33 +0000 Subject: [PATCH] fix: git with no user info --- testscript/script_test.go | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/testscript/script_test.go b/testscript/script_test.go index 1b8e35fe6ca39fe9c8f64c0a817df73dd4a8ee02..ce4f9b33a5dff3d9f135de8a3eb17390b3b2c9e0 100644 --- a/testscript/script_test.go +++ b/testscript/script_test.go @@ -69,7 +69,6 @@ func TestScript(t *testing.T) { UpdateScripts: *update, Cmds: map[string]func(ts *testscript.TestScript, neg bool, args []string){ "soft": func(ts *testscript.TestScript, neg bool, args []string) { - // TODO: maybe use plain ssh client here? args = append( sshArgs, append([]string{ @@ -80,18 +79,22 @@ func TestScript(t *testing.T) { ) check(ts, ts.Exec("ssh", args...), neg) }, - "git": func(ts *testscript.TestScript, _ bool, args []string) { + "git": func(ts *testscript.TestScript, neg bool, args []string) { ts.Setenv( "GIT_SSH_COMMAND", strings.Join(append([]string{"ssh"}, sshArgs...), " "), ) - ts.Check(ts.Exec("git", args...)) + args = append([]string{ + "-c", "user.email=john@example.com", + "-c", "user.name=John Doe", + }, args...) + check(ts, ts.Exec("git", args...), neg) }, - "mkreadme": func(ts *testscript.TestScript, _ bool, args []string) { + "mkreadme": func(ts *testscript.TestScript, neg bool, args []string) { if len(args) != 1 { ts.Fatalf("must have exactly 1 arg, the filename, got %d", len(args)) } - ts.Check(os.WriteFile(ts.MkAbs(args[0]), []byte("# example\ntest project"), 0o644)) + check(ts, os.WriteFile(ts.MkAbs(args[0]), []byte("# example\ntest project"), 0o644), neg) }, }, Setup: func(e *testscript.Env) error {