package userimpl import ( "context" "testing" "github.com/grafana/grafana/pkg/services/org/orgtest" "github.com/grafana/grafana/pkg/services/user" "github.com/stretchr/testify/require" ) func TestUserService(t *testing.T) { userStore := newUserStoreFake() orgService := orgtest.NewOrgServiceFake() userService := Service{ store: userStore, orgService: orgService, } t.Run("create user", func(t *testing.T) { _, err := userService.Create(context.Background(), &user.CreateUserCommand{}) require.NoError(t, err) }) } type FakeUserStore struct { ExpectedUser *user.User ExpectedError error } func newUserStoreFake() *FakeUserStore { return &FakeUserStore{} } func (f *FakeUserStore) Get(ctx context.Context, query *user.User) (*user.User, error) { return f.ExpectedUser, f.ExpectedError } func (f *FakeUserStore) Insert(ctx context.Context, query *user.User) (int64, error) { return 0, f.ExpectedError }