Skip to content
This repository has been archived by the owner on Sep 1, 2020. It is now read-only.

Commit

Permalink
Make email a unique key for users & update functional tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Ullaakut committed Aug 27, 2018
1 parent 65fe881 commit 0a03e02
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
4 changes: 3 additions & 1 deletion data/users.sql
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@ CREATE TABLE `users` (
`password` varchar(255) NOT NULL,
`token_user_id` varchar(255) NOT NULL,
`is_admin` tinyint(4) NOT NULL DEFAULT '1',
PRIMARY KEY (`id`)
PRIMARY KEY (`id`),
UNIQUE KEY (email)

) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;

-- 2018-08-03 05:08:01
13 changes: 13 additions & 0 deletions test/functional_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,19 @@ func TestRegister(t *testing.T) {

expectedCode: 201,
},
{
description: "register user that already exists - should fail",

body: []byte(`
{
"email": "bob-admin@vance-refrigeration.com",
"password": "refrigerator2000",
"is_admin": true
}
`),

expectedCode: 500,
},
}

for _, test := range tests {
Expand Down

0 comments on commit 0a03e02

Please sign in to comment.