MCPcopy Create free account
hub / github.com/alibaba/open-code-review / initRepo

Function initRepo

internal/gitcmd/runner_test.go:14–40  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

12)
13
14func initRepo(t *testing.T) string {
15 t.Helper()
16 dir := t.TempDir()
17 run := func(args ...string) {
18 cmd := exec.Command("git", args...)
19 cmd.Dir = dir
20 cmd.Env = append(os.Environ(),
21 "GIT_AUTHOR_NAME=test",
22 "GIT_AUTHOR_EMAIL=test@test.com",
23 "GIT_COMMITTER_NAME=test",
24 "GIT_COMMITTER_EMAIL=test@test.com",
25 )
26 out, err := cmd.CombinedOutput()
27 if err != nil {
28 t.Fatalf("git %v: %v\n%s", args, err, out)
29 }
30 }
31 run("init")
32 run("config", "user.email", "test@test.com")
33 run("config", "user.name", "test")
34 if err := os.WriteFile(filepath.Join(dir, "hello.txt"), []byte("hello\n"), 0644); err != nil {
35 t.Fatal(err)
36 }
37 run("add", "hello.txt")
38 run("commit", "-m", "init")
39 return dir
40}
41
42func TestRunner_New(t *testing.T) {
43 r := New(0)

Callers 5

TestRunner_RunFunction · 0.85
TestRunner_OutputFunction · 0.85
TestRunner_RunSplitFunction · 0.85
TestRunner_StreamFunction · 0.85

Calls 1

runFunction · 0.85

Tested by

no test coverage detected