/
mock.go
48 lines (41 loc) · 1.13 KB
/
mock.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
package authentication
import (
"github.com/stretchr/testify/mock"
)
// AuthMock mock of auth service
type AuthMock struct {
mock.Mock
}
// V2GetUserCode mock of auth service
func (a *AuthMock) V2GetUserCode() (uc *UserCode, err error) {
args := a.Called()
if res, ok := args.Get(0).(*UserCode); ok {
return res, nil
}
return nil, args.Error(1)
}
func (a *AuthMock) V2Authenticate(authType, authCode, authCodeVerifier, refreshToken string) (c *V2Credentials, err error) {
args := a.Called(authType, authCode, authCodeVerifier, refreshToken)
if res, ok := args.Get(0).(*V2Credentials); ok {
return res, nil
}
return nil, args.Error(1)
}
// Authenticate mock of auth service
func (a *AuthMock) Authenticate(user, pass string) (c *Credentials, err error) {
args := a.Called(user, pass)
if res, ok := args.Get(0).(*Credentials); ok {
return res, nil
}
return nil, args.Error(1)
}
// Validate mock of auth service
func (a *AuthMock) Validate() (err error) {
args := a.Called()
return args.Error(0)
}
// GetToken mock of auth service
func (a *AuthMock) GetToken() (token string) {
args := a.Called()
return args.Get(0).(string)
}