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) { ...@@ -79,7 +79,7 @@ func TestDeniedClone(t *testing.T) {
} }
func TestAllowedPush(t *testing.T) { func TestAllowedPush(t *testing.T) {
branch := preparePushRepo(t) preparePushRepo(t)
// Prepare the test server and backend // Prepare the test server and backend
ts := testAuthServer(200, `{"GL_ID":"user-123"}`) ts := testAuthServer(200, `{"GL_ID":"user-123"}`)
...@@ -94,13 +94,13 @@ func TestAllowedPush(t *testing.T) { ...@@ -94,13 +94,13 @@ func TestAllowedPush(t *testing.T) {
} }
// Perform the git push // 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 pushCmd.Dir = checkoutDir
runOrFail(t, pushCmd) runOrFail(t, pushCmd)
} }
func TestDeniedPush(t *testing.T) { func TestDeniedPush(t *testing.T) {
branch := preparePushRepo(t) preparePushRepo(t)
// Prepare the test server and backend // Prepare the test server and backend
ts := testAuthServer(403, "Access denied") ts := testAuthServer(403, "Access denied")
...@@ -115,7 +115,7 @@ func TestDeniedPush(t *testing.T) { ...@@ -115,7 +115,7 @@ func TestDeniedPush(t *testing.T) {
} }
// Perform the git push // 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 pushCmd.Dir = checkoutDir
out, err := pushCmd.CombinedOutput() out, err := pushCmd.CombinedOutput()
t.Logf("%s", out) t.Logf("%s", out)
...@@ -124,17 +124,17 @@ func TestDeniedPush(t *testing.T) { ...@@ -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 { if err := os.RemoveAll(scratchDir); err != nil {
t.Fatal(err) t.Fatal(err)
} }
cloneCmd := exec.Command("git", "clone", path.Join(testRepoRoot, testRepo), checkoutDir) cloneCmd := exec.Command("git", "clone", path.Join(testRepoRoot, testRepo), checkoutDir)
runOrFail(t, cloneCmd) runOrFail(t, cloneCmd)
branch := fmt.Sprintf("branch-%d", time.Now().UnixNano()) return
branchCmd := exec.Command("git", "branch", branch) }
branchCmd.Dir = checkoutDir
runOrFail(t, branchCmd) func newBranch() string {
return branch return fmt.Sprintf("branch-%d", time.Now().UnixNano())
} }
func testAuthServer(code int, body string) *httptest.Server { 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