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