-
Notifications
You must be signed in to change notification settings - Fork 1
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
43e2e96
commit ab9faf6
Showing
184 changed files
with
3,888 additions
and
803 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
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
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 |
---|---|---|
|
@@ -7,6 +7,7 @@ import ( | |
"github.com/stretchr/testify/assert" | ||
"github.com/stretchr/testify/mock" | ||
|
||
"github.com/khanzadimahdi/testproject/domain" | ||
"github.com/khanzadimahdi/testproject/domain/user" | ||
"github.com/khanzadimahdi/testproject/infrastructure/crypto/ecdsa" | ||
"github.com/khanzadimahdi/testproject/infrastructure/email" | ||
|
@@ -17,9 +18,8 @@ import ( | |
|
||
func TestUseCase_Execute(t *testing.T) { | ||
privateKey, err := ecdsa.Generate() | ||
if err != nil { | ||
t.Error("unexpected error") | ||
} | ||
assert.NoError(t, err) | ||
|
||
j := jwt.NewJWT(privateKey, privateKey.Public()) | ||
|
||
mailFrom := "[email protected]" | ||
|
@@ -79,6 +79,35 @@ func TestUseCase_Execute(t *testing.T) { | |
assert.Equal(t, &expectedResponse, response) | ||
}) | ||
|
||
t.Run("user not found", func(t *testing.T) { | ||
var ( | ||
userRepository users.MockUsersRepository | ||
mailer email.MockMailer | ||
renderer template.MockRenderer | ||
|
||
request = Request{ | ||
Identity: "[email protected]", | ||
} | ||
expectedResponse = Response{ | ||
ValidationErrors: validationErrors{ | ||
"identity": "identity (email/username) not exists", | ||
}, | ||
} | ||
) | ||
|
||
userRepository.On("GetOneByIdentity", request.Identity).Once().Return(user.User{}, domain.ErrNotExists) | ||
defer userRepository.AssertExpectations(t) | ||
|
||
response, err := NewUseCase(&userRepository, j, &mailer, mailFrom, &renderer).Execute(request) | ||
|
||
renderer.AssertNotCalled(t, "Render") | ||
mailer.AssertNotCalled(t, "SendMail") | ||
|
||
assert.NoError(t, err) | ||
assert.NotNil(t, response) | ||
assert.Equal(t, &expectedResponse, response) | ||
}) | ||
|
||
t.Run("error on finding user", func(t *testing.T) { | ||
var ( | ||
userRepository users.MockUsersRepository | ||
|
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
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
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 |
---|---|---|
|
@@ -18,9 +18,8 @@ import ( | |
|
||
func TestUseCase_Execute(t *testing.T) { | ||
privateKey, err := ecdsa.Generate() | ||
if err != nil { | ||
t.Error("unexpected error") | ||
} | ||
assert.NoError(t, err) | ||
|
||
j := jwt.NewJWT(privateKey, privateKey.Public()) | ||
|
||
mailFrom := "[email protected]" | ||
|
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
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
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
Oops, something went wrong.