fleet/server/service/service_labels_test.go
Zach Wasserman fb32f0cf40
Remove kolide types and packages from backend (#974)
Generally renamed `kolide` -> `fleet`
2021-06-06 15:07:29 -07:00

30 lines
688 B
Go

package service
import (
"testing"
"github.com/fleetdm/fleet/server/config"
"github.com/fleetdm/fleet/server/datastore/inmem"
"github.com/fleetdm/fleet/server/fleet"
"github.com/fleetdm/fleet/server/test"
"github.com/stretchr/testify/assert"
)
func TestGetLabel(t *testing.T) {
ds, err := inmem.New(config.TestConfig())
assert.Nil(t, err)
svc := newTestService(ds, nil, nil)
label := &fleet.Label{
Name: "foo",
Query: "select * from foo;",
}
label, err = ds.NewLabel(label)
assert.Nil(t, err)
assert.NotZero(t, label.ID)
labelVerify, err := svc.GetLabel(test.UserContext(test.UserAdmin), label.ID)
assert.Nil(t, err)
assert.Equal(t, label.ID, labelVerify.ID)
}