initial commit

This commit is contained in:
dhax 2017-09-25 18:23:11 +02:00
commit 93d8310491
46 changed files with 3379 additions and 0 deletions

61
testing/mock/authStore.go Normal file
View file

@ -0,0 +1,61 @@
package mock
import "github.com/dhax/go-base/models"
type AuthStore struct {
GetByIDFn func(id int) (*models.Account, error)
GetByIDInvoked bool
GetByEmailFn func(email string) (*models.Account, error)
GetByEmailInvoked bool
GetByRefreshTokenFn func(token string) (*models.Account, *models.Token, error)
GetByRefreshTokenInvoked bool
UpdateAccountFn func(a *models.Account) error
UpdateAccountInvoked bool
SaveRefreshTokenFn func(u *models.Token) error
SaveRefreshTokenInvoked bool
DeleteRefreshTokenFn func(t *models.Token) error
DeleteRefreshTokenInvoked bool
PurgeExpiredTokenFn func() error
PurgeExpiredTokenInvoked bool
}
func (s *AuthStore) GetByID(id int) (*models.Account, error) {
s.GetByIDInvoked = true
return s.GetByIDFn(id)
}
func (s *AuthStore) GetByEmail(email string) (*models.Account, error) {
s.GetByEmailInvoked = true
return s.GetByEmailFn(email)
}
func (s *AuthStore) GetByRefreshToken(token string) (*models.Account, *models.Token, error) {
s.GetByRefreshTokenInvoked = true
return s.GetByRefreshTokenFn(token)
}
func (s *AuthStore) UpdateAccount(a *models.Account) error {
s.UpdateAccountInvoked = true
return s.UpdateAccountFn(a)
}
func (s *AuthStore) SaveRefreshToken(u *models.Token) error {
s.SaveRefreshTokenInvoked = true
return s.SaveRefreshTokenFn(u)
}
func (s *AuthStore) DeleteRefreshToken(t *models.Token) error {
s.DeleteRefreshTokenInvoked = true
return s.DeleteRefreshTokenFn(t)
}
func (s *AuthStore) PurgeExpiredToken() error {
s.PurgeExpiredTokenInvoked = true
return s.PurgeExpiredTokenFn()
}