fix: move testdb/testuser to a mock dir to be clearer
This commit is contained in:
parent
addddb152a
commit
79739e3751
@ -20,7 +20,7 @@
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
|
||||
package usecase
|
||||
package repomock
|
||||
|
||||
import "context"
|
||||
|
@ -20,7 +20,7 @@
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
|
||||
package usecase
|
||||
package repomock
|
||||
|
||||
import (
|
||||
"context"
|
@ -27,13 +27,14 @@ import (
|
||||
"testing"
|
||||
|
||||
"git.vinchent.xyz/vinchent/howmuch/internal/howmuch/model"
|
||||
"git.vinchent.xyz/vinchent/howmuch/internal/howmuch/usecase/usecase/repomock"
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
func TestCreateUser(t *testing.T) {
|
||||
t.Run("normal create", func(t *testing.T) {
|
||||
ctx := context.Background()
|
||||
userUsecase := NewUserUsecase(&TestUserRepository{}, &TestDBRepository{})
|
||||
userUsecase := NewUserUsecase(&repomock.TestUserRepository{}, &repomock.TestDBRepository{})
|
||||
input := &model.User{
|
||||
Email: "a@b.c",
|
||||
FirstName: "James",
|
||||
@ -50,7 +51,7 @@ func TestCreateUser(t *testing.T) {
|
||||
|
||||
t.Run("duplicate create", func(t *testing.T) {
|
||||
ctx := context.Background()
|
||||
userUsecase := NewUserUsecase(&TestUserRepository{}, &TestDBRepository{})
|
||||
userUsecase := NewUserUsecase(&repomock.TestUserRepository{}, &repomock.TestDBRepository{})
|
||||
input := &model.User{
|
||||
Email: "duplicate@error.com",
|
||||
FirstName: "James",
|
||||
@ -77,7 +78,7 @@ func TestUserExist(t *testing.T) {
|
||||
{"query error", &model.User{
|
||||
Email: "query@error.com",
|
||||
Password: "strongHashed",
|
||||
}, UserTestDummyErr, false},
|
||||
}, repomock.UserTestDummyErr, false},
|
||||
{"user doesn not exist", &model.User{
|
||||
Email: "inexist@error.com",
|
||||
Password: "strongHashed",
|
||||
@ -90,7 +91,7 @@ func TestUserExist(t *testing.T) {
|
||||
|
||||
for _, tst := range testCases {
|
||||
ctx := context.Background()
|
||||
userUsecase := NewUserUsecase(&TestUserRepository{}, &TestDBRepository{})
|
||||
userUsecase := NewUserUsecase(&repomock.TestUserRepository{}, &repomock.TestDBRepository{})
|
||||
|
||||
got, err := userUsecase.Exist(ctx, tst.User)
|
||||
assert.ErrorIs(t, err, tst.ExpErr)
|
||||
|
Loading…
Reference in New Issue
Block a user