diff --git a/gandalftest/server.go b/gandalftest/server.go index 25621b2..566f6c1 100644 --- a/gandalftest/server.go +++ b/gandalftest/server.go @@ -225,11 +225,11 @@ func (s *GandalfServer) createUser(w http.ResponseWriter, r *http.Request) { http.Error(w, err.Error(), http.StatusBadRequest) return } - s.users = append(s.users, usr.Name) if _, ok := s.keys[usr.Name]; ok { http.Error(w, "user already exists", http.StatusConflict) return } + s.users = append(s.users, usr.Name) keys := make([]key, 0, len(usr.Keys)) for name, body := range usr.Keys { keys = append(keys, key{Name: name, Body: body}) diff --git a/gandalftest/server_test.go b/gandalftest/server_test.go index e314b4d..f031469 100644 --- a/gandalftest/server_test.go +++ b/gandalftest/server_test.go @@ -174,6 +174,7 @@ func (s *S) TestCreateDuplicateUser(c *check.C) { server.ServeHTTP(recorder, request) c.Assert(recorder.Code, check.Equals, http.StatusConflict) c.Assert(recorder.Body.String(), check.Equals, "user already exists\n") + c.Assert(server.Users(), check.DeepEquals, []string{"someuser"}) } func (s *S) TestRemoveUser(c *check.C) {