2022-06-28 07:32:25 -05:00
|
|
|
package usertest
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
|
|
|
|
"github.com/grafana/grafana/pkg/services/user"
|
|
|
|
)
|
|
|
|
|
|
|
|
type FakeUserService struct {
|
2022-08-11 06:28:55 -05:00
|
|
|
ExpectedUser *user.User
|
|
|
|
ExpectedSignedInUser *user.SignedInUser
|
|
|
|
ExpectedError error
|
|
|
|
ExpectedSetUsingOrgError error
|
2022-06-28 07:32:25 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
func NewUserServiceFake() *FakeUserService {
|
|
|
|
return &FakeUserService{}
|
|
|
|
}
|
|
|
|
|
|
|
|
func (f *FakeUserService) Create(ctx context.Context, cmd *user.CreateUserCommand) (*user.User, error) {
|
|
|
|
return f.ExpectedUser, f.ExpectedError
|
|
|
|
}
|
2022-07-19 09:01:05 -05:00
|
|
|
|
|
|
|
func (f *FakeUserService) Delete(ctx context.Context, cmd *user.DeleteUserCommand) error {
|
|
|
|
return f.ExpectedError
|
|
|
|
}
|
2022-08-02 09:58:05 -05:00
|
|
|
|
|
|
|
func (f *FakeUserService) GetByID(ctx context.Context, query *user.GetUserByIDQuery) (*user.User, error) {
|
|
|
|
return f.ExpectedUser, f.ExpectedError
|
|
|
|
}
|
2022-08-04 06:22:43 -05:00
|
|
|
|
|
|
|
func (f *FakeUserService) GetByLogin(ctx context.Context, query *user.GetUserByLoginQuery) (*user.User, error) {
|
|
|
|
return f.ExpectedUser, f.ExpectedError
|
|
|
|
}
|
2022-08-04 06:47:30 -05:00
|
|
|
|
|
|
|
func (f *FakeUserService) GetByEmail(ctx context.Context, query *user.GetUserByEmailQuery) (*user.User, error) {
|
|
|
|
return f.ExpectedUser, f.ExpectedError
|
|
|
|
}
|
2022-08-04 07:22:44 -05:00
|
|
|
|
|
|
|
func (f *FakeUserService) Update(ctx context.Context, cmd *user.UpdateUserCommand) error {
|
|
|
|
return f.ExpectedError
|
|
|
|
}
|
2022-08-04 08:05:05 -05:00
|
|
|
|
|
|
|
func (f *FakeUserService) ChangePassword(ctx context.Context, cmd *user.ChangeUserPasswordCommand) error {
|
|
|
|
return f.ExpectedError
|
|
|
|
}
|
2022-08-04 08:44:14 -05:00
|
|
|
|
|
|
|
func (f *FakeUserService) UpdateLastSeenAt(ctx context.Context, cmd *user.UpdateUserLastSeenAtCommand) error {
|
|
|
|
return f.ExpectedError
|
|
|
|
}
|
2022-08-11 06:28:55 -05:00
|
|
|
|
|
|
|
func (f *FakeUserService) SetUsingOrg(ctx context.Context, cmd *user.SetUsingOrgCommand) error {
|
|
|
|
return f.ExpectedSetUsingOrgError
|
|
|
|
}
|
|
|
|
|
|
|
|
func (f *FakeUserService) GetSignedInUserWithCacheCtx(ctx context.Context, query *user.GetSignedInUserQuery) (*user.SignedInUser, error) {
|
|
|
|
return f.ExpectedSignedInUser, f.ExpectedError
|
|
|
|
}
|