fleet/cmd/fleetctl/users_test.go
Martin Angers 4f4185372d
Add support for context in datastore/mysql layer (#1962)
This is just to pass down the context to the datastore layer, it doesn't
use it just yet - this will be in a follow-up PR.
2021-09-14 08:11:07 -04:00

33 lines
674 B
Go

package main
import (
"context"
"testing"
"github.com/fleetdm/fleet/v4/server/fleet"
"github.com/stretchr/testify/assert"
)
func TestUserDelete(t *testing.T) {
server, ds := runServerWithMockedDS(t)
defer server.Close()
ds.UserByEmailFunc = func(ctx context.Context, email string) (*fleet.User, error) {
return &fleet.User{
ID: 42,
Name: "test1",
Email: "user1@test.com",
}, nil
}
deletedUser := uint(0)
ds.DeleteUserFunc = func(ctx context.Context, id uint) error {
deletedUser = id
return nil
}
assert.Equal(t, "", runAppForTest(t, []string{"user", "delete", "--email", "user1@test.com"}))
assert.Equal(t, uint(42), deletedUser)
}