mirror of
https://github.com/empayre/fleet.git
synced 2024-11-07 01:15:22 +00:00
57 lines
1.1 KiB
Go
57 lines
1.1 KiB
Go
package service
|
|
|
|
import (
|
|
"context"
|
|
"testing"
|
|
|
|
"github.com/fleetdm/fleet/server/config"
|
|
"github.com/fleetdm/fleet/server/datastore/inmem"
|
|
"github.com/fleetdm/fleet/server/kolide"
|
|
"github.com/stretchr/testify/assert"
|
|
)
|
|
|
|
func TestListPacks(t *testing.T) {
|
|
ds, err := inmem.New(config.TestConfig())
|
|
assert.Nil(t, err)
|
|
|
|
svc, err := newTestService(ds, nil, nil)
|
|
assert.Nil(t, err)
|
|
|
|
ctx := context.Background()
|
|
|
|
queries, err := svc.ListPacks(ctx, kolide.ListOptions{})
|
|
assert.Nil(t, err)
|
|
assert.Len(t, queries, 0)
|
|
|
|
_, err = ds.NewPack(&kolide.Pack{
|
|
Name: "foo",
|
|
})
|
|
assert.Nil(t, err)
|
|
|
|
queries, err = svc.ListPacks(ctx, kolide.ListOptions{})
|
|
assert.Nil(t, err)
|
|
assert.Len(t, queries, 1)
|
|
}
|
|
|
|
func TestGetPack(t *testing.T) {
|
|
ds, err := inmem.New(config.TestConfig())
|
|
assert.Nil(t, err)
|
|
|
|
svc, err := newTestService(ds, nil, nil)
|
|
assert.Nil(t, err)
|
|
|
|
ctx := context.Background()
|
|
|
|
pack := &kolide.Pack{
|
|
Name: "foo",
|
|
}
|
|
_, err = ds.NewPack(pack)
|
|
assert.Nil(t, err)
|
|
assert.NotZero(t, pack.ID)
|
|
|
|
packVerify, err := svc.GetPack(ctx, pack.ID)
|
|
assert.Nil(t, err)
|
|
|
|
assert.Equal(t, pack.ID, packVerify.ID)
|
|
}
|