Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
G
go-gitlab
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
go
go-gitlab
Commits
8666683d
Commit
8666683d
authored
Dec 03, 2015
by
Gabor Pipicz
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Adjust POST/PUT tests: search the body for request payload
parent
3159fab2
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
17 additions
and
2 deletions
+17
-2
gitlab_test.go
gitlab_test.go
+15
-0
projects_test.go
projects_test.go
+1
-1
services_test.go
services_test.go
+1
-1
No files found.
gitlab_test.go
View file @
8666683d
package
gitlab
import
(
"encoding/json"
"io/ioutil"
"net/http"
"net/http/httptest"
...
...
@@ -74,6 +75,20 @@ func testBody(t *testing.T, r *http.Request, want string) {
}
}
func
testJsonBody
(
t
*
testing
.
T
,
r
*
http
.
Request
,
want
values
)
{
b
,
err
:=
ioutil
.
ReadAll
(
r
.
Body
)
if
err
!=
nil
{
t
.
Errorf
(
"Error reading request body: %v"
,
err
)
}
var
got
values
json
.
Unmarshal
(
b
,
&
got
)
if
!
reflect
.
DeepEqual
(
got
,
want
)
{
t
.
Errorf
(
"Request parameters: %v, want %v"
,
got
,
want
)
}
}
func
responseBody
(
w
http
.
ResponseWriter
,
filename
string
)
{
body
,
_
:=
ioutil
.
ReadFile
(
filename
)
w
.
Write
([]
byte
(
body
))
...
...
projects_test.go
View file @
8666683d
...
...
@@ -177,7 +177,7 @@ func TestCreateProject(t *testing.T) {
mux
.
HandleFunc
(
"/projects"
,
func
(
w
http
.
ResponseWriter
,
r
*
http
.
Request
)
{
testMethod
(
t
,
r
,
"POST"
)
test
FormValues
(
t
,
r
,
values
{
test
JsonBody
(
t
,
r
,
values
{
"name"
:
"n"
,
})
...
...
services_test.go
View file @
8666683d
...
...
@@ -13,7 +13,7 @@ func TestSetDroneCIService(t *testing.T) {
mux
.
HandleFunc
(
"/projects/1/services/drone-ci"
,
func
(
w
http
.
ResponseWriter
,
r
*
http
.
Request
)
{
testMethod
(
t
,
r
,
"PUT"
)
test
FormValues
(
t
,
r
,
values
{
test
JsonBody
(
t
,
r
,
values
{
"token"
:
"t"
,
"drone_url"
:
"u"
,
"enable_ssl_verification"
:
"true"
,
...
...
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