You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
35 lines
670 B
Go
35 lines
670 B
Go
package mock
|
|
|
|
import "git.runcible.io/learning/ratchet/internal/model"
|
|
|
|
var MockEmail = "drew@fake.com"
|
|
var MockPassword = "thisisinsecure"
|
|
|
|
type UserService struct{}
|
|
|
|
func (u *UserService) Insert(name, email, password string) (int, error) {
|
|
switch email {
|
|
case "dupe@example.com":
|
|
return 0, model.ErrDuplicateEmail
|
|
default:
|
|
return 1, nil
|
|
}
|
|
}
|
|
|
|
func (u *UserService) Authenticate(email, password string) (int, error) {
|
|
if email == MockEmail && password == MockPassword {
|
|
return 1, nil
|
|
}
|
|
|
|
return 0, model.ErrInvalidCredentials
|
|
}
|
|
|
|
func (u *UserService) Exists(id int) (bool, error) {
|
|
switch id {
|
|
case 1:
|
|
return true, nil
|
|
default:
|
|
return false, nil
|
|
}
|
|
}
|