fleet/server/service/service_labels_test.go
Zachary Wasserman 003ad9b5fa
Delete spec entities by name instead of ID (#1755)
With the UI, deleting by ID made sense. With fleetctl, we now want to delete
by name. Transition only the methods used for spec related entities, as others
will be removed soon.
2018-05-04 11:05:55 -07:00

34 lines
680 B
Go

package service
import (
"context"
"testing"
"github.com/kolide/fleet/server/config"
"github.com/kolide/fleet/server/datastore/inmem"
"github.com/kolide/fleet/server/kolide"
"github.com/stretchr/testify/assert"
)
func TestGetLabel(t *testing.T) {
ds, err := inmem.New(config.TestConfig())
assert.Nil(t, err)
svc, err := newTestService(ds, nil)
assert.Nil(t, err)
ctx := context.Background()
label := &kolide.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(ctx, label.ID)
assert.Nil(t, err)
assert.Equal(t, label.ID, labelVerify.ID)
}