Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-workhorse
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
iv
gitlab-workhorse
Commits
c71b3d6e
Commit
c71b3d6e
authored
Aug 02, 2015
by
Jacob Vosmaer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove `git branch` step
parent
806290c2
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
10 deletions
+10
-10
main_test.go
main_test.go
+10
-10
No files found.
main_test.go
View file @
c71b3d6e
...
...
@@ -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
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment