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

Function initRepo

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

Source from the content-addressed store, hash-verified

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