mirror of
https://github.com/empayre/fleet.git
synced 2024-11-07 01:15:22 +00:00
484c6153e3
* wip * Add delete user command and translator * Add host transfer command * Add changes file * Undo bad refactor * Fix copypaste error * Implement with interfaces instead of assertions * Ad documentation and simplify implementation further * Update docs/1-Using-Fleet/3-REST-API.md Co-authored-by: Zach Wasserman <zach@fleetdm.com> Co-authored-by: Zach Wasserman <zach@fleetdm.com>
32 lines
621 B
Go
32 lines
621 B
Go
package main
|
|
|
|
import (
|
|
"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(email string) (*fleet.User, error) {
|
|
return &fleet.User{
|
|
ID: 42,
|
|
Name: "test1",
|
|
Email: "user1@test.com",
|
|
}, nil
|
|
}
|
|
|
|
deletedUser := uint(0)
|
|
|
|
ds.DeleteUserFunc = func(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)
|
|
}
|