/
mockrepository.go
61 lines (44 loc) · 1.1 KB
/
mockrepository.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
package user
import (
"github.com/stretchr/testify/mock"
)
type MockRepository struct {
mock.Mock
BaseRepository
}
func (repo *MockRepository) GetUser(userId string) (user *User, err error) {
args := repo.Called(userId)
if args.Get(0) != nil {
user = args.Get(0).(*User)
}
return user, args.Error(1)
}
func (repo *MockRepository) GetUserByEmail(email string) (user *User, err error) {
args := repo.Called(email)
if args.Get(0) != nil {
user = args.Get(0).(*User)
}
return user, args.Error(1)
}
func (repo *MockRepository) PutUser(user *User) error {
args := repo.Called(user)
return args.Error(0)
}
func (repo *MockRepository) GetUsersByCountry(cc string) (users []*User, err error) {
args := repo.Called(cc)
if args.Get(0) != nil {
users = args.Get(0).([]*User)
}
return users, args.Error(1)
}
func (repo *MockRepository) DeleteUser(id string) error {
args := repo.Called(id)
return args.Error(0)
}
func (repo *MockRepository) GetAllUsers() (users []*User, err error) {
args := repo.Called()
if args.Get(0) != nil {
users = args.Get(0).([]*User)
}
return users, args.Error(1)
}