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

Function initRepo

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

Source from the content-addressed store, hash-verified

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

Calls 1

runFunction · 0.50

Tested by

no test coverage detected