fleet/cmd/fleetctl/logout_test.go
Tomas Touceda a18e09b613
Simplify fleetctl implementation and improve testing (#3830)
* Simplify fleetctl implementation and improve testing

* Add a few more

* Handle not founds better

* Fix tests

* Check that logout ds func is called
2022-01-24 16:40:51 -03:00

30 lines
628 B
Go

package main
import (
"context"
"testing"
"time"
"github.com/fleetdm/fleet/v4/server/fleet"
"github.com/stretchr/testify/assert"
)
func TestLogout(t *testing.T) {
_, ds := runServerWithMockedDS(t)
ds.SessionByIDFunc = func(ctx context.Context, id uint) (*fleet.Session, error) {
return &fleet.Session{
ID: 333,
AccessedAt: time.Now(),
UserID: 123,
Key: "12344321",
}, nil
}
ds.DestroySessionFunc = func(ctx context.Context, session *fleet.Session) error {
return nil
}
assert.Equal(t, "", runAppForTest(t, []string{"logout"}))
assert.True(t, ds.DestroySessionFuncInvoked)
}