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