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
259cc194
Commit
259cc194
authored
May 12, 2017
by
Sander van Harmelen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Cleanup a bit and improve the readability of some tests
parent
85c5274e
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
39 additions
and
25 deletions
+39
-25
gitlab.go
gitlab.go
+1
-1
gitlab_test.go
gitlab_test.go
+1
-1
projects.go
projects.go
+2
-2
projects_test.go
projects_test.go
+35
-21
No files found.
gitlab.go
View file @
259cc194
...
...
@@ -34,7 +34,7 @@ import (
const
(
libraryVersion
=
"0.2.0"
defaultBaseURL
=
"https://gitlab.com/api/v
3
/"
defaultBaseURL
=
"https://gitlab.com/api/v
4
/"
userAgent
=
"go-gitlab/"
+
libraryVersion
)
...
...
gitlab_test.go
View file @
259cc194
...
...
@@ -132,7 +132,7 @@ func TestCheckResponse(t *testing.T) {
t
.
Fatal
(
"Expected error response."
)
}
want
:=
"GET https://gitlab.com/api/v
3
/test: 400 {error: message 1}, {message: {embed1: {prop3: [msg 1, msg2]}}, {embed2: {prop4: [some msg]}}, {prop1: [message 1, message 2]}, {prop2: [message 3]}}"
want
:=
"GET https://gitlab.com/api/v
4
/test: 400 {error: message 1}, {message: {embed1: {prop3: [msg 1, msg2]}}, {embed2: {prop4: [some msg]}}, {prop1: [message 1, message 2]}, {prop2: [message 3]}}"
if
errResp
.
Error
()
!=
want
{
t
.
Errorf
(
"Expected error: %s, got %s"
,
want
,
errResp
.
Error
())
...
...
projects.go
View file @
259cc194
...
...
@@ -155,11 +155,11 @@ type ListProjectsOptions struct {
Sort
*
string
`url:"sort,omitempty" json:"sort,omitempty"`
Search
*
string
`url:"search,omitempty" json:"search,omitempty"`
Simple
*
bool
`url:"simple,omitempty" json:"simple,omitempty"`
Visibility
*
VisibilityLevelValue
`url:"visibility,omitempty" json:"visibility,omitempty"`
Statistics
*
bool
`url:"statistics,omitempty" json:"statistics,omitempty"`
Owned
*
bool
`url:"owned,omitempty" json:"owned,omitempty"`
Membership
*
bool
`url:"membership,omitempty" json:"membership,omitempty"`
Starred
*
bool
`url:"starred,omitempty" json:"starred,omitempty"`
Statistics
*
bool
`url:"statistics,omitempty" json:"statistics,omitempty"`
Visibility
*
VisibilityLevelValue
`url:"visibility,omitempty" json:"visibility,omitempty"`
}
// ListProjects gets a list of projects accessible by the authenticated user.
...
...
projects_test.go
View file @
259cc194
...
...
@@ -22,17 +22,21 @@ func TestListProjects(t *testing.T) {
"search"
:
"query"
,
"simple"
:
"true"
,
"visibility"
:
"public"
,
"statistics"
:
"false"
,
"owned"
:
"false"
,
"membership"
:
"false"
,
"starred"
:
"false"
,
})
fmt
.
Fprint
(
w
,
`[{"id":1},{"id":2}]`
)
})
opt
:=
&
ListProjectsOptions
{
ListOptions
{
2
,
3
},
Bool
(
true
),
String
(
"name"
),
String
(
"asc"
),
String
(
"query"
),
Bool
(
true
),
VisibilityLevel
(
PublicVisibility
),
Bool
(
false
),
Bool
(
false
),
Bool
(
false
),
Bool
(
false
)}
projects
,
_
,
err
:=
client
.
Projects
.
ListProjects
(
opt
)
opt
:=
&
ListProjectsOptions
{
ListOptions
:
ListOptions
{
2
,
3
},
Archived
:
Bool
(
true
),
OrderBy
:
String
(
"name"
),
Sort
:
String
(
"asc"
),
Search
:
String
(
"query"
),
Simple
:
Bool
(
true
),
Visibility
:
VisibilityLevel
(
PublicVisibility
),
}
projects
,
_
,
err
:=
client
.
Projects
.
ListProjects
(
opt
)
if
err
!=
nil
{
t
.
Errorf
(
"Projects.ListProjects returned error: %v"
,
err
)
}
...
...
@@ -57,18 +61,24 @@ func TestListOwnedProjects(t *testing.T) {
"sort"
:
"asc"
,
"search"
:
"query"
,
"simple"
:
"true"
,
"owned"
:
"true"
,
"visibility"
:
"public"
,
"statistics"
:
"false"
,
"owned"
:
"true"
,
"membership"
:
"false"
,
"starred"
:
"false"
,
})
fmt
.
Fprint
(
w
,
`[{"id":1},{"id":2}]`
)
})
opt
:=
&
ListProjectsOptions
{
ListOptions
{
2
,
3
},
Bool
(
true
),
String
(
"name"
),
String
(
"asc"
),
String
(
"query"
),
Bool
(
true
),
VisibilityLevel
(
PublicVisibility
),
Bool
(
false
),
Bool
(
true
),
Bool
(
false
),
Bool
(
false
)}
projects
,
_
,
err
:=
client
.
Projects
.
ListProjects
(
opt
)
opt
:=
&
ListProjectsOptions
{
ListOptions
:
ListOptions
{
2
,
3
},
Archived
:
Bool
(
true
),
OrderBy
:
String
(
"name"
),
Sort
:
String
(
"asc"
),
Search
:
String
(
"query"
),
Simple
:
Bool
(
true
),
Owned
:
Bool
(
true
),
Visibility
:
VisibilityLevel
(
PublicVisibility
),
}
projects
,
_
,
err
:=
client
.
Projects
.
ListProjects
(
opt
)
if
err
!=
nil
{
t
.
Errorf
(
"Projects.ListOwnedProjects returned error: %v"
,
err
)
}
...
...
@@ -93,18 +103,24 @@ func TestListStarredProjects(t *testing.T) {
"sort"
:
"asc"
,
"search"
:
"query"
,
"simple"
:
"true"
,
"starred"
:
"true"
,
"visibility"
:
"public"
,
"statistics"
:
"false"
,
"owned"
:
"false"
,
"membership"
:
"false"
,
"starred"
:
"true"
,
})
fmt
.
Fprint
(
w
,
`[{"id":1},{"id":2}]`
)
})
opt
:=
&
ListProjectsOptions
{
ListOptions
{
2
,
3
},
Bool
(
true
),
String
(
"name"
),
String
(
"asc"
),
String
(
"query"
),
Bool
(
true
),
VisibilityLevel
(
PublicVisibility
),
Bool
(
false
),
Bool
(
false
),
Bool
(
false
),
Bool
(
true
)}
projects
,
_
,
err
:=
client
.
Projects
.
ListProjects
(
opt
)
opt
:=
&
ListProjectsOptions
{
ListOptions
:
ListOptions
{
2
,
3
},
Archived
:
Bool
(
true
),
OrderBy
:
String
(
"name"
),
Sort
:
String
(
"asc"
),
Search
:
String
(
"query"
),
Simple
:
Bool
(
true
),
Starred
:
Bool
(
true
),
Visibility
:
VisibilityLevel
(
PublicVisibility
),
}
projects
,
_
,
err
:=
client
.
Projects
.
ListProjects
(
opt
)
if
err
!=
nil
{
t
.
Errorf
(
"Projects.ListStarredProjects returned error: %v"
,
err
)
}
...
...
@@ -126,7 +142,6 @@ func TestGetProject_byID(t *testing.T) {
want
:=
&
Project
{
ID
:
1
}
project
,
_
,
err
:=
client
.
Projects
.
GetProject
(
1
)
if
err
!=
nil
{
t
.
Fatalf
(
"Projects.GetProject returns an error: %v"
,
err
)
}
...
...
@@ -148,7 +163,6 @@ func TestGetProject_byName(t *testing.T) {
want
:=
&
Project
{
ID
:
1
}
project
,
_
,
err
:=
client
.
Projects
.
GetProject
(
"namespace/name"
)
if
err
!=
nil
{
t
.
Fatalf
(
"Projects.GetProject returns an error: %v"
,
err
)
}
...
...
@@ -172,8 +186,8 @@ func TestCreateProject(t *testing.T) {
})
opt
:=
&
CreateProjectOptions
{
Name
:
String
(
"n"
)}
project
,
_
,
err
:=
client
.
Projects
.
CreateProject
(
opt
)
project
,
_
,
err
:=
client
.
Projects
.
CreateProject
(
opt
)
if
err
!=
nil
{
t
.
Errorf
(
"Projects.CreateProject returned error: %v"
,
err
)
}
...
...
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