mirror of
https://github.com/empayre/fleet.git
synced 2024-11-06 17:05:18 +00:00
402303bc5d
* Add All Linux label * Change name to Linux instead of All Linux to see if e2e likes it better * Revert "Change name to Linux instead of All Linux to see if e2e likes it better" This reverts commit 26b79f214e3b744e73270c544f89bb698575f6ea. * Fix all linux label insert
45 lines
1.0 KiB
Go
45 lines
1.0 KiB
Go
package service
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/fleetdm/fleet/v4/server/datastore/mysql"
|
|
"github.com/fleetdm/fleet/v4/server/fleet"
|
|
"github.com/fleetdm/fleet/v4/server/test"
|
|
"github.com/stretchr/testify/assert"
|
|
"github.com/stretchr/testify/require"
|
|
)
|
|
|
|
func TestGetLabel(t *testing.T) {
|
|
ds := mysql.CreateMySQLDS(t)
|
|
defer ds.Close()
|
|
|
|
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)
|
|
}
|
|
|
|
func TestGetLabels(t *testing.T) {
|
|
ds := mysql.CreateMySQLDS(t)
|
|
defer ds.Close()
|
|
|
|
require.NoError(t, ds.MigrateTables())
|
|
require.NoError(t, ds.MigrateData())
|
|
|
|
svc := newTestService(ds, nil, nil)
|
|
|
|
labels, err := svc.ListLabels(test.UserContext(test.UserAdmin), fleet.ListOptions{Page: 0, PerPage: 1000})
|
|
require.NoError(t, err)
|
|
require.Len(t, labels, 7)
|
|
}
|