Commit c71b3d6e authored by Jacob Vosmaer's avatar Jacob Vosmaer

Remove `git branch` step

parent 806290c2
......@@ -79,7 +79,7 @@ func TestDeniedClone(t *testing.T) {
}
func TestAllowedPush(t *testing.T) {
branch := preparePushRepo(t)
preparePushRepo(t)
// Prepare the test server and backend
ts := testAuthServer(200, `{"GL_ID":"user-123"}`)
......@@ -94,13 +94,13 @@ func TestAllowedPush(t *testing.T) {
}
// Perform the git push
pushCmd := exec.Command("git", "push", remote, branch)
pushCmd := exec.Command("git", "push", remote, fmt.Sprintf("master:%s", newBranch()))
pushCmd.Dir = checkoutDir
runOrFail(t, pushCmd)
}
func TestDeniedPush(t *testing.T) {
branch := preparePushRepo(t)
preparePushRepo(t)
// Prepare the test server and backend
ts := testAuthServer(403, "Access denied")
......@@ -115,7 +115,7 @@ func TestDeniedPush(t *testing.T) {
}
// Perform the git push
pushCmd := exec.Command("git", "push", remote, branch)
pushCmd := exec.Command("git", "push", "-v", remote, fmt.Sprintf("master:%s", newBranch()))
pushCmd.Dir = checkoutDir
out, err := pushCmd.CombinedOutput()
t.Logf("%s", out)
......@@ -124,17 +124,17 @@ func TestDeniedPush(t *testing.T) {
}
}
func preparePushRepo(t *testing.T) string {
func preparePushRepo(t *testing.T) {
if err := os.RemoveAll(scratchDir); err != nil {
t.Fatal(err)
}
cloneCmd := exec.Command("git", "clone", path.Join(testRepoRoot, testRepo), checkoutDir)
runOrFail(t, cloneCmd)
branch := fmt.Sprintf("branch-%d", time.Now().UnixNano())
branchCmd := exec.Command("git", "branch", branch)
branchCmd.Dir = checkoutDir
runOrFail(t, branchCmd)
return branch
return
}
func newBranch() string {
return fmt.Sprintf("branch-%d", time.Now().UnixNano())
}
func testAuthServer(code int, body string) *httptest.Server {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment