feat: improvements in entity domain logic

This commit is contained in:
Elton Minetto
2020-10-07 22:57:54 -03:00
parent 098477169a
commit 83c00526b2
10 changed files with 35 additions and 30 deletions
+6 -3
View File
@@ -27,9 +27,13 @@ func TestValidatePassword(t *testing.T) {
func TestAddBook(t *testing.T) {
u, _ := entity.NewUser("[email protected]", "new_password", "Steve", "Jobs")
err := u.AddBook(entity.NewID())
bID := entity.NewID()
err := u.AddBook(bID)
assert.Nil(t, err)
assert.Equal(t, 1, len(u.Books))
err = u.AddBook(bID)
assert.Equal(t, domain.ErrBookAlreadyBorrowed, err)
}
func TestRemoveBook(t *testing.T) {
@@ -101,8 +105,7 @@ func TestUserValidate(t *testing.T) {
}
for _, tc := range tests {
u, err := entity.NewUser(tc.email, tc.password, tc.firstName, tc.lastName)
err = u.Validate()
_, err := entity.NewUser(tc.email, tc.password, tc.firstName, tc.lastName)
assert.Equal(t, err, tc.want)
}