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
4cffd791
Commit
4cffd791
authored
Mar 07, 2019
by
Sander van Harmelen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix a linter issue
parent
d6cc43b2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
23 additions
and
13 deletions
+23
-13
users.go
users.go
+5
-3
users_test.go
users_test.go
+18
-10
No files found.
users.go
View file @
4cffd791
...
@@ -17,14 +17,16 @@
...
@@ -17,14 +17,16 @@
package
gitlab
package
gitlab
import
(
import
(
"errors"
"fmt"
"fmt"
"time"
"time"
)
)
// List a couple of standard errors.
var
(
var
(
ErrUserBlockPrevented
=
fmt
.
Errorf
(
"Cannot block a user that is already blocked by LDAP synchronization"
)
ErrUserBlockPrevented
=
errors
.
New
(
"Cannot block a user that is already blocked by LDAP synchronization"
)
ErrUserNotFound
=
fmt
.
Errorf
(
"User does not exist"
)
ErrUserNotFound
=
errors
.
New
(
"User does not exist"
)
ErrUserUnblockPrevented
=
fmt
.
Errorf
(
"Cannot unblock a user that is blocked by LDAP synchronization"
)
ErrUserUnblockPrevented
=
errors
.
New
(
"Cannot unblock a user that is blocked by LDAP synchronization"
)
)
)
// UsersService handles communication with the user related methods of
// UsersService handles communication with the user related methods of
...
...
users_test.go
View file @
4cffd791
...
@@ -11,7 +11,8 @@ func TestBlockUser(t *testing.T) {
...
@@ -11,7 +11,8 @@ func TestBlockUser(t *testing.T) {
mux
,
server
,
client
:=
setup
()
mux
,
server
,
client
:=
setup
()
defer
teardown
(
server
)
defer
teardown
(
server
)
mux
.
HandleFunc
(
"/users/1/block"
,
func
(
w
http
.
ResponseWriter
,
r
*
http
.
Request
)
{
path
:=
fmt
.
Sprintf
(
"/%susers/1/block"
,
apiVersionPath
)
mux
.
HandleFunc
(
path
,
func
(
w
http
.
ResponseWriter
,
r
*
http
.
Request
)
{
testMethod
(
t
,
r
,
"POST"
)
testMethod
(
t
,
r
,
"POST"
)
w
.
WriteHeader
(
http
.
StatusCreated
)
w
.
WriteHeader
(
http
.
StatusCreated
)
})
})
...
@@ -26,7 +27,8 @@ func TestBlockUser_UserNotFound(t *testing.T) {
...
@@ -26,7 +27,8 @@ func TestBlockUser_UserNotFound(t *testing.T) {
mux
,
server
,
client
:=
setup
()
mux
,
server
,
client
:=
setup
()
defer
teardown
(
server
)
defer
teardown
(
server
)
mux
.
HandleFunc
(
"/users/1/block"
,
func
(
w
http
.
ResponseWriter
,
r
*
http
.
Request
)
{
path
:=
fmt
.
Sprintf
(
"/%susers/1/block"
,
apiVersionPath
)
mux
.
HandleFunc
(
path
,
func
(
w
http
.
ResponseWriter
,
r
*
http
.
Request
)
{
testMethod
(
t
,
r
,
"POST"
)
testMethod
(
t
,
r
,
"POST"
)
w
.
WriteHeader
(
http
.
StatusNotFound
)
w
.
WriteHeader
(
http
.
StatusNotFound
)
})
})
...
@@ -41,7 +43,8 @@ func TestBlockUser_BlockPrevented(t *testing.T) {
...
@@ -41,7 +43,8 @@ func TestBlockUser_BlockPrevented(t *testing.T) {
mux
,
server
,
client
:=
setup
()
mux
,
server
,
client
:=
setup
()
defer
teardown
(
server
)
defer
teardown
(
server
)
mux
.
HandleFunc
(
"/users/1/block"
,
func
(
w
http
.
ResponseWriter
,
r
*
http
.
Request
)
{
path
:=
fmt
.
Sprintf
(
"/%susers/1/block"
,
apiVersionPath
)
mux
.
HandleFunc
(
path
,
func
(
w
http
.
ResponseWriter
,
r
*
http
.
Request
)
{
testMethod
(
t
,
r
,
"POST"
)
testMethod
(
t
,
r
,
"POST"
)
w
.
WriteHeader
(
http
.
StatusForbidden
)
w
.
WriteHeader
(
http
.
StatusForbidden
)
})
})
...
@@ -56,7 +59,8 @@ func TestBlockUser_UnknownError(t *testing.T) {
...
@@ -56,7 +59,8 @@ func TestBlockUser_UnknownError(t *testing.T) {
mux
,
server
,
client
:=
setup
()
mux
,
server
,
client
:=
setup
()
defer
teardown
(
server
)
defer
teardown
(
server
)
mux
.
HandleFunc
(
"/users/1/block"
,
func
(
w
http
.
ResponseWriter
,
r
*
http
.
Request
)
{
path
:=
fmt
.
Sprintf
(
"/%susers/1/block"
,
apiVersionPath
)
mux
.
HandleFunc
(
path
,
func
(
w
http
.
ResponseWriter
,
r
*
http
.
Request
)
{
testMethod
(
t
,
r
,
"POST"
)
testMethod
(
t
,
r
,
"POST"
)
w
.
WriteHeader
(
http
.
StatusTeapot
)
w
.
WriteHeader
(
http
.
StatusTeapot
)
})
})
...
@@ -73,7 +77,7 @@ func TestBlockUser_BadResponseFromNet(t *testing.T) {
...
@@ -73,7 +77,7 @@ func TestBlockUser_BadResponseFromNet(t *testing.T) {
client
:=
NewClient
(
nil
,
""
)
client
:=
NewClient
(
nil
,
""
)
client
.
SetBaseURL
(
""
)
client
.
SetBaseURL
(
""
)
want
:=
"Post /users/1/block: unsupported protocol scheme
\"\"
"
want
:=
fmt
.
Sprintf
(
"Post /%susers/1/block: unsupported protocol scheme
\"\"
"
,
apiVersionPath
)
err
:=
client
.
Users
.
BlockUser
(
1
)
err
:=
client
.
Users
.
BlockUser
(
1
)
if
err
.
Error
()
!=
want
{
if
err
.
Error
()
!=
want
{
...
@@ -86,7 +90,8 @@ func TestUnblockUser(t *testing.T) {
...
@@ -86,7 +90,8 @@ func TestUnblockUser(t *testing.T) {
mux
,
server
,
client
:=
setup
()
mux
,
server
,
client
:=
setup
()
defer
teardown
(
server
)
defer
teardown
(
server
)
mux
.
HandleFunc
(
"/users/1/unblock"
,
func
(
w
http
.
ResponseWriter
,
r
*
http
.
Request
)
{
path
:=
fmt
.
Sprintf
(
"/%susers/1/unblock"
,
apiVersionPath
)
mux
.
HandleFunc
(
path
,
func
(
w
http
.
ResponseWriter
,
r
*
http
.
Request
)
{
testMethod
(
t
,
r
,
"POST"
)
testMethod
(
t
,
r
,
"POST"
)
w
.
WriteHeader
(
http
.
StatusCreated
)
w
.
WriteHeader
(
http
.
StatusCreated
)
})
})
...
@@ -101,7 +106,8 @@ func TestUnblockUser_UserNotFound(t *testing.T) {
...
@@ -101,7 +106,8 @@ func TestUnblockUser_UserNotFound(t *testing.T) {
mux
,
server
,
client
:=
setup
()
mux
,
server
,
client
:=
setup
()
defer
teardown
(
server
)
defer
teardown
(
server
)
mux
.
HandleFunc
(
"/users/1/unblock"
,
func
(
w
http
.
ResponseWriter
,
r
*
http
.
Request
)
{
path
:=
fmt
.
Sprintf
(
"/%susers/1/unblock"
,
apiVersionPath
)
mux
.
HandleFunc
(
path
,
func
(
w
http
.
ResponseWriter
,
r
*
http
.
Request
)
{
testMethod
(
t
,
r
,
"POST"
)
testMethod
(
t
,
r
,
"POST"
)
w
.
WriteHeader
(
http
.
StatusNotFound
)
w
.
WriteHeader
(
http
.
StatusNotFound
)
})
})
...
@@ -116,7 +122,8 @@ func TestUnblockUser_UnblockPrevented(t *testing.T) {
...
@@ -116,7 +122,8 @@ func TestUnblockUser_UnblockPrevented(t *testing.T) {
mux
,
server
,
client
:=
setup
()
mux
,
server
,
client
:=
setup
()
defer
teardown
(
server
)
defer
teardown
(
server
)
mux
.
HandleFunc
(
"/users/1/unblock"
,
func
(
w
http
.
ResponseWriter
,
r
*
http
.
Request
)
{
path
:=
fmt
.
Sprintf
(
"/%susers/1/unblock"
,
apiVersionPath
)
mux
.
HandleFunc
(
path
,
func
(
w
http
.
ResponseWriter
,
r
*
http
.
Request
)
{
testMethod
(
t
,
r
,
"POST"
)
testMethod
(
t
,
r
,
"POST"
)
w
.
WriteHeader
(
http
.
StatusForbidden
)
w
.
WriteHeader
(
http
.
StatusForbidden
)
})
})
...
@@ -131,7 +138,8 @@ func TestUnblockUser_UnknownError(t *testing.T) {
...
@@ -131,7 +138,8 @@ func TestUnblockUser_UnknownError(t *testing.T) {
mux
,
server
,
client
:=
setup
()
mux
,
server
,
client
:=
setup
()
defer
teardown
(
server
)
defer
teardown
(
server
)
mux
.
HandleFunc
(
"/users/1/unblock"
,
func
(
w
http
.
ResponseWriter
,
r
*
http
.
Request
)
{
path
:=
fmt
.
Sprintf
(
"/%susers/1/unblock"
,
apiVersionPath
)
mux
.
HandleFunc
(
path
,
func
(
w
http
.
ResponseWriter
,
r
*
http
.
Request
)
{
testMethod
(
t
,
r
,
"POST"
)
testMethod
(
t
,
r
,
"POST"
)
w
.
WriteHeader
(
http
.
StatusTeapot
)
w
.
WriteHeader
(
http
.
StatusTeapot
)
})
})
...
@@ -148,7 +156,7 @@ func TestUnblockUser_BadResponseFromNet(t *testing.T) {
...
@@ -148,7 +156,7 @@ func TestUnblockUser_BadResponseFromNet(t *testing.T) {
client
:=
NewClient
(
nil
,
""
)
client
:=
NewClient
(
nil
,
""
)
client
.
SetBaseURL
(
""
)
client
.
SetBaseURL
(
""
)
want
:=
"Post /users/1/unblock: unsupported protocol scheme
\"\"
"
want
:=
fmt
.
Sprintf
(
"Post /%susers/1/unblock: unsupported protocol scheme
\"\"
"
,
apiVersionPath
)
err
:=
client
.
Users
.
UnblockUser
(
1
)
err
:=
client
.
Users
.
UnblockUser
(
1
)
if
err
.
Error
()
!=
want
{
if
err
.
Error
()
!=
want
{
...
...
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