-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
232ab25
commit 9202146
Showing
2 changed files
with
18 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,7 +10,7 @@ import ( | |
qt "github.com/frankban/quicktest" | ||
) | ||
|
||
func Test_registerHandler(t *testing.T) { | ||
func TestRegisterHandler(t *testing.T) { | ||
c := qt.New(t) | ||
defer func() { | ||
if err := testDB.Reset(); err != nil { | ||
|
@@ -25,12 +25,12 @@ func Test_registerHandler(t *testing.T) { | |
method: http.MethodPost, | ||
body: []byte("invalid body"), | ||
expectedStatus: http.StatusBadRequest, | ||
expectedBody: mustMarshall(ErrMalformedBody), | ||
expectedBody: mustMarshal(ErrMalformedBody), | ||
}, | ||
{ | ||
uri: registerURL, | ||
method: http.MethodPost, | ||
body: mustMarshall(&UserInfo{ | ||
body: mustMarshal(&UserInfo{ | ||
Email: "[email protected]", | ||
Password: "password", | ||
FirstName: "first", | ||
|
@@ -41,79 +41,79 @@ func Test_registerHandler(t *testing.T) { | |
{ | ||
uri: registerURL, | ||
method: http.MethodPost, | ||
body: mustMarshall(&UserInfo{ | ||
body: mustMarshal(&UserInfo{ | ||
Email: "[email protected]", | ||
Password: "password", | ||
FirstName: "first", | ||
LastName: "last", | ||
}), | ||
expectedStatus: http.StatusInternalServerError, | ||
expectedBody: mustMarshall(ErrGenericInternalServerError), | ||
expectedBody: mustMarshal(ErrGenericInternalServerError), | ||
}, | ||
{ | ||
uri: registerURL, | ||
method: http.MethodPost, | ||
body: mustMarshall(&UserInfo{ | ||
body: mustMarshal(&UserInfo{ | ||
Email: "[email protected]", | ||
Password: "password", | ||
FirstName: "first", | ||
LastName: "", | ||
}), | ||
expectedStatus: http.StatusBadRequest, | ||
expectedBody: mustMarshall(ErrMalformedBody.Withf("last name is empty")), | ||
expectedBody: mustMarshal(ErrMalformedBody.Withf("last name is empty")), | ||
}, | ||
{ | ||
uri: registerURL, | ||
method: http.MethodPost, | ||
body: mustMarshall(&UserInfo{ | ||
body: mustMarshal(&UserInfo{ | ||
Email: "[email protected]", | ||
Password: "password", | ||
FirstName: "", | ||
LastName: "last", | ||
}), | ||
expectedStatus: http.StatusBadRequest, | ||
expectedBody: mustMarshall(ErrMalformedBody.Withf("first name is empty")), | ||
expectedBody: mustMarshal(ErrMalformedBody.Withf("first name is empty")), | ||
}, | ||
{ | ||
uri: registerURL, | ||
method: http.MethodPost, | ||
body: mustMarshall(&UserInfo{ | ||
body: mustMarshal(&UserInfo{ | ||
Email: "invalid", | ||
Password: "password", | ||
FirstName: "first", | ||
LastName: "last", | ||
}), | ||
expectedStatus: http.StatusBadRequest, | ||
expectedBody: mustMarshall(ErrEmailMalformed), | ||
expectedBody: mustMarshal(ErrEmailMalformed), | ||
}, | ||
{ | ||
uri: registerURL, | ||
method: http.MethodPost, | ||
body: mustMarshall(&UserInfo{ | ||
body: mustMarshal(&UserInfo{ | ||
Email: "", | ||
Password: "password", | ||
FirstName: "first", | ||
LastName: "last", | ||
}), | ||
expectedStatus: http.StatusBadRequest, | ||
expectedBody: mustMarshall(ErrEmailMalformed), | ||
expectedBody: mustMarshal(ErrEmailMalformed), | ||
}, | ||
{ | ||
uri: registerURL, | ||
method: http.MethodPost, | ||
body: mustMarshall(&UserInfo{ | ||
body: mustMarshal(&UserInfo{ | ||
Email: "[email protected]", | ||
Password: "short", | ||
FirstName: "first", | ||
LastName: "last", | ||
}), | ||
expectedStatus: http.StatusBadRequest, | ||
expectedBody: mustMarshall(ErrPasswordTooShort), | ||
expectedBody: mustMarshal(ErrPasswordTooShort), | ||
}, | ||
{ | ||
uri: registerURL, | ||
method: http.MethodPost, | ||
body: mustMarshall(&UserInfo{ | ||
body: mustMarshal(&UserInfo{ | ||
Email: "[email protected]", | ||
Password: "", | ||
FirstName: "first", | ||
|