diff options
Diffstat (limited to 'examples/common_test.go')
-rw-r--r-- | examples/common_test.go | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/examples/common_test.go b/examples/common_test.go index e75b492..9ec1f05 100644 --- a/examples/common_test.go +++ b/examples/common_test.go @@ -2,6 +2,7 @@ package examples import ( "flag" + "fmt" "go/build" "io/ioutil" "os" @@ -20,6 +21,7 @@ var args = map[string][]string{ "clone": []string{defaultURL, tempFolder()}, "progress": []string{defaultURL, tempFolder()}, "open": []string{filepath.Join(cloneRepository(defaultURL, tempFolder()), ".git")}, + "push": []string{setEmptyRemote(filepath.Join(cloneRepository(defaultURL, tempFolder()), ".git"))}, } var ignored = map[string]bool{ @@ -85,6 +87,27 @@ func cloneRepository(url, folder string) string { return folder } +func createBareRepository(dir string) string { + cmd := exec.Command("git", "init", "--bare", dir) + err := cmd.Run() + CheckIfError(err) + + return dir +} + +func setEmptyRemote(dir string) string { + remote := createBareRepository(tempFolder()) + setRemote(dir, fmt.Sprintf("file://%s", remote)) + return dir +} + +func setRemote(local, remote string) { + cmd := exec.Command("git", "remote", "set-url", "origin", remote) + cmd.Dir = local + err := cmd.Run() + CheckIfError(err) +} + func testExample(t *testing.T, name, example string) { cmd := exec.Command("go", append([]string{ "run", filepath.Join(example), |