(t *testing.T)
| 15 | ) |
| 16 | |
| 17 | func 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 | |
| 45 | func TestRunner_New(t *testing.T) { |
| 46 | r := New(0) |
no test coverage detected