Commit d6cc43b2 authored by Joe Rocklin's avatar Joe Rocklin Committed by Sander van Harmelen

Fix error names based on linter output

parent 5e1c7f37
......@@ -22,9 +22,9 @@ import (
)
var (
UserBlockPreventedError = fmt.Errorf("Cannot block a user that is already blocked by LDAP synchronization")
UserNotFoundError = fmt.Errorf("User does not exist")
UserUnblockPreventedError = fmt.Errorf("Cannot unblock a user that is blocked by LDAP synchronization")
ErrUserBlockPrevented = fmt.Errorf("Cannot block a user that is already blocked by LDAP synchronization")
ErrUserNotFound = fmt.Errorf("User does not exist")
ErrUserUnblockPrevented = fmt.Errorf("Cannot unblock a user that is blocked by LDAP synchronization")
)
// UsersService handles communication with the user related methods of
......@@ -438,9 +438,9 @@ func (s *UsersService) BlockUser(user int, options ...OptionFunc) error {
case 201:
return nil
case 403:
return UserBlockPreventedError
return ErrUserBlockPrevented
case 404:
return UserNotFoundError
return ErrUserNotFound
default:
return fmt.Errorf("Received unexpected result code: %d", resp.StatusCode)
}
......@@ -466,9 +466,9 @@ func (s *UsersService) UnblockUser(user int, options ...OptionFunc) error {
case 201:
return nil
case 403:
return UserUnblockPreventedError
return ErrUserUnblockPrevented
case 404:
return UserNotFoundError
return ErrUserNotFound
default:
return fmt.Errorf("Received unexpected result code: %d", resp.StatusCode)
}
......
......@@ -32,8 +32,8 @@ func TestBlockUser_UserNotFound(t *testing.T) {
})
err := client.Users.BlockUser(1)
if err != UserNotFoundError {
t.Errorf("Users.BlockUser error.\nExpected: %+v\n Got: %+v", UserNotFoundError, err)
if err != ErrUserNotFound {
t.Errorf("Users.BlockUser error.\nExpected: %+v\n Got: %+v", ErrUserNotFound, err)
}
}
......@@ -47,8 +47,8 @@ func TestBlockUser_BlockPrevented(t *testing.T) {
})
err := client.Users.BlockUser(1)
if err != UserBlockPreventedError {
t.Errorf("Users.BlockUser error.\nExpected: %+v\n Got: %+v", UserBlockPreventedError, err)
if err != ErrUserBlockPrevented {
t.Errorf("Users.BlockUser error.\nExpected: %+v\n Got: %+v", ErrUserBlockPrevented, err)
}
}
......@@ -107,8 +107,8 @@ func TestUnblockUser_UserNotFound(t *testing.T) {
})
err := client.Users.UnblockUser(1)
if err != UserNotFoundError {
t.Errorf("Users.UnblockUser error.\nExpected: %+v\n Got: %+v", UserNotFoundError, err)
if err != ErrUserNotFound {
t.Errorf("Users.UnblockUser error.\nExpected: %+v\n Got: %+v", ErrUserNotFound, err)
}
}
......@@ -122,8 +122,8 @@ func TestUnblockUser_UnblockPrevented(t *testing.T) {
})
err := client.Users.UnblockUser(1)
if err != UserUnblockPreventedError {
t.Errorf("Users.UnblockUser error.\nExpected: %+v\n Got: %+v", UserUnblockPreventedError, err)
if err != ErrUserUnblockPrevented {
t.Errorf("Users.UnblockUser error.\nExpected: %+v\n Got: %+v", ErrUserUnblockPrevented, err)
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment