示例#1
0
func run(t *testing.T, tmpDir string, env []string, args ...string) string {
	internal := &git{root: tmpDir}
	out, code, err := internal.captureEnv(env, args...)
	ut.AssertEqualf(t, 0, code, "%s", out)
	ut.AssertEqual(t, nil, err)
	return out
}
示例#2
0
func setup(t *testing.T, td string, files map[string]string) scm.Change {
	fooDir := filepath.Join(td, "src", "foo")
	ut.AssertEqual(t, nil, os.MkdirAll(fooDir, 0700))
	for f, c := range files {
		p := filepath.Join(fooDir, f)
		ut.AssertEqual(t, nil, os.MkdirAll(filepath.Dir(p), 0700))
		ut.AssertEqual(t, nil, ioutil.WriteFile(p, []byte(c), 0600))
	}
	out, code, err := internal.Capture(fooDir, nil, "git", "init")
	ut.AssertEqualf(t, 0, code, out)
	ut.AssertEqual(t, nil, err)
	// It's important to add the files to the index, otherwise they will be
	// ignored.
	out, code, err = internal.Capture(fooDir, nil, "git", "add", ".")
	ut.AssertEqualf(t, 0, code, out)
	ut.AssertEqual(t, nil, err)

	repo, err := scm.GetRepo(fooDir, td)
	ut.AssertEqual(t, nil, err)
	change, err := repo.Between(scm.Current, scm.Initial, nil)
	ut.AssertEqual(t, nil, err)
	ut.AssertEqual(t, true, change != nil)
	return change
}