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
48a4b33a
Commit
48a4b33a
authored
Nov 23, 2015
by
Martin Sefcik
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Url encoding fix
parent
d5898459
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
31 additions
and
5 deletions
+31
-5
gitlab.go
gitlab.go
+2
-4
gitlab_test.go
gitlab_test.go
+6
-0
projects_test.go
projects_test.go
+23
-1
No files found.
gitlab.go
View file @
48a4b33a
...
...
@@ -196,13 +196,11 @@ func (c *Client) SetBaseURL(urlStr string) error {
// specified, the value pointed to by body is JSON encoded and included as the
// request body.
func
(
c
*
Client
)
NewRequest
(
method
,
path
string
,
opt
interface
{})
(
*
http
.
Request
,
error
)
{
rel
,
err
:=
url
.
Parse
(
path
)
u
,
err
:=
url
.
Parse
(
c
.
baseURL
.
String
()
+
path
)
if
err
!=
nil
{
return
nil
,
err
}
u
:=
*
c
.
baseURL
.
ResolveReference
(
rel
)
q
,
err
:=
query
.
Values
(
opt
)
if
err
!=
nil
{
return
nil
,
err
...
...
@@ -211,7 +209,7 @@ func (c *Client) NewRequest(method, path string, opt interface{}) (*http.Request
req
:=
&
http
.
Request
{
Method
:
method
,
URL
:
&
u
,
URL
:
u
,
Proto
:
"HTTP/1.1"
,
ProtoMajor
:
1
,
ProtoMinor
:
1
,
...
...
gitlab_test.go
View file @
48a4b33a
...
...
@@ -32,6 +32,12 @@ func teardown(server *httptest.Server) {
server
.
Close
()
}
func
testUrl
(
t
*
testing
.
T
,
r
*
http
.
Request
,
want
string
)
{
if
got
:=
r
.
URL
.
String
();
got
!=
want
{
t
.
Errorf
(
"Request url: %s, want %s"
,
got
,
want
)
}
}
func
testMethod
(
t
*
testing
.
T
,
r
*
http
.
Request
,
want
string
)
{
if
got
:=
r
.
Method
;
got
!=
want
{
t
.
Errorf
(
"Request method: %v, want %v"
,
got
,
want
)
...
...
projects_test.go
View file @
48a4b33a
...
...
@@ -100,7 +100,7 @@ func TestListAllProjects(t *testing.T) {
}
}
func
TestGetProject
(
t
*
testing
.
T
)
{
func
TestGetProject
_byID
(
t
*
testing
.
T
)
{
mux
,
server
,
client
:=
setup
()
defer
teardown
(
server
)
...
...
@@ -121,6 +121,28 @@ func TestGetProject(t *testing.T) {
}
}
func
TestGetProject_byName
(
t
*
testing
.
T
)
{
mux
,
server
,
client
:=
setup
()
defer
teardown
(
server
)
mux
.
HandleFunc
(
"/projects/"
,
func
(
w
http
.
ResponseWriter
,
r
*
http
.
Request
)
{
testUrl
(
t
,
r
,
"/projects/namespace%2Fname"
)
testMethod
(
t
,
r
,
"GET"
)
fmt
.
Fprint
(
w
,
`{"id":1}`
)
})
want
:=
&
Project
{
ID
:
Int
(
1
)}
project
,
_
,
err
:=
client
.
Projects
.
GetProject
(
"namespace/name"
)
if
err
!=
nil
{
t
.
Fatalf
(
"Projects.GetProject returns an error: %v"
,
err
)
}
if
!
reflect
.
DeepEqual
(
want
,
project
)
{
t
.
Errorf
(
"Projects.GetProject returned %+v, want %+v"
,
project
,
want
)
}
}
func
TestSearchProjects
(
t
*
testing
.
T
)
{
mux
,
server
,
client
:=
setup
()
defer
teardown
(
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