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
|
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
// SOFTWARE.
|
// SOFTWARE.
|
||||||
|
|
||||||
package usecase
|
package repomock
|
||||||
|
|
||||||
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 usecase
|
package repomock
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
@ -27,13 +27,14 @@ 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/usecase/repomock"
|
||||||
"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(&TestUserRepository{}, &TestDBRepository{})
|
userUsecase := NewUserUsecase(&repomock.TestUserRepository{}, &repomock.TestDBRepository{})
|
||||||
input := &model.User{
|
input := &model.User{
|
||||||
Email: "a@b.c",
|
Email: "a@b.c",
|
||||||
FirstName: "James",
|
FirstName: "James",
|
||||||
@ -50,7 +51,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(&TestUserRepository{}, &TestDBRepository{})
|
userUsecase := NewUserUsecase(&repomock.TestUserRepository{}, &repomock.TestDBRepository{})
|
||||||
input := &model.User{
|
input := &model.User{
|
||||||
Email: "duplicate@error.com",
|
Email: "duplicate@error.com",
|
||||||
FirstName: "James",
|
FirstName: "James",
|
||||||
@ -77,7 +78,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",
|
||||||
}, UserTestDummyErr, false},
|
}, repomock.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",
|
||||||
@ -90,7 +91,7 @@ func TestUserExist(t *testing.T) {
|
|||||||
|
|
||||||
for _, tst := range testCases {
|
for _, tst := range testCases {
|
||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
userUsecase := NewUserUsecase(&TestUserRepository{}, &TestDBRepository{})
|
userUsecase := NewUserUsecase(&repomock.TestUserRepository{}, &repomock.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