Skip to content

Commit

Permalink
fix client test
Browse files Browse the repository at this point in the history
  • Loading branch information
mwhudson committed Aug 10, 2016
1 parent 69688f5 commit 577eeed
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
6 changes: 4 additions & 2 deletions client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -355,14 +355,16 @@ type CreateUserResult struct {

// createUserRequest holds the user creation request
type createUserRequest struct {
EMail string `json:"email"`
EMail string `json:"email"`
Sudoer bool `json:"sudoer"`
}

// CreateUser creates a user from the given mail address
func (client *Client) CreateUser(mail string, sudoer bool) (*CreateUserResult, error) {
var createResult CreateUserResult
b, err := json.Marshal(createUserRequest{
EMail: mail,
EMail: mail,
Sudoer: sudoer,
})
if err != nil {
return nil, err
Expand Down
8 changes: 5 additions & 3 deletions client/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -282,15 +282,17 @@ func (cs *clientSuite) TestClientCreateUser(c *check.C) {
cs.rsp = `{
"type": "sync",
"result": {
"username": "karl"
"username": "karl",
"ssh_key_count": 1
}
}`
rsp, err := cs.cli.CreateUser("popper@lse.ac.uk")
rsp, err := cs.cli.CreateUser("popper@lse.ac.uk", true)
c.Assert(cs.req.Method, check.Equals, "POST")
c.Assert(cs.req.URL.Path, check.Equals, "/v2/create-user")
c.Assert(err, check.IsNil)
c.Assert(rsp, check.DeepEquals, &client.CreateUserResult{
Username: "karl",
Username: "karl",
SshKeyCount: 1,
})
}

Expand Down

0 comments on commit 577eeed

Please sign in to comment.