mirror of
https://github.com/fleetdm/fleet
synced 2026-05-22 16:39:01 +00:00
parent
5ad1ad1ffd
commit
4800856bf7
3 changed files with 9 additions and 9 deletions
|
|
@ -404,27 +404,27 @@ func setupLabelSpecsTest(t *testing.T, ds fleet.Datastore) []*fleet.LabelSpec {
|
|||
}
|
||||
|
||||
expectedSpecs := []*fleet.LabelSpec{
|
||||
&fleet.LabelSpec{
|
||||
{
|
||||
Name: "foo",
|
||||
Query: "select * from foo",
|
||||
Description: "foo description",
|
||||
Platform: "darwin",
|
||||
},
|
||||
&fleet.LabelSpec{
|
||||
{
|
||||
Name: "bar",
|
||||
Query: "select * from bar",
|
||||
},
|
||||
&fleet.LabelSpec{
|
||||
{
|
||||
Name: "bing",
|
||||
Query: "select * from bing",
|
||||
},
|
||||
&fleet.LabelSpec{
|
||||
{
|
||||
Name: "All Hosts",
|
||||
Query: "SELECT 1",
|
||||
LabelType: fleet.LabelTypeBuiltIn,
|
||||
LabelMembershipType: fleet.LabelMembershipTypeManual,
|
||||
},
|
||||
&fleet.LabelSpec{
|
||||
{
|
||||
Name: "Manual Label",
|
||||
LabelMembershipType: fleet.LabelMembershipTypeManual,
|
||||
Hosts: []string{
|
||||
|
|
@ -453,14 +453,14 @@ func testApplyLabelSpecsRoundtrip(t *testing.T, ds fleet.Datastore) {
|
|||
|
||||
specs, err := ds.GetLabelSpecs()
|
||||
require.Nil(t, err)
|
||||
assert.Equal(t, expectedSpecs, specs)
|
||||
test.ElementsMatchSkipTimestampsID(t, expectedSpecs, specs)
|
||||
|
||||
// Should be idempotent
|
||||
err = ds.ApplyLabelSpecs(expectedSpecs)
|
||||
require.Nil(t, err)
|
||||
specs, err = ds.GetLabelSpecs()
|
||||
require.Nil(t, err)
|
||||
assert.Equal(t, expectedSpecs, specs)
|
||||
test.ElementsMatchSkipTimestampsID(t, expectedSpecs, specs)
|
||||
}
|
||||
|
||||
func testLabelIDsByName(t *testing.T, ds fleet.Datastore) {
|
||||
|
|
|
|||
|
|
@ -113,7 +113,7 @@ func batchHostnames(hostnames []string) [][]string {
|
|||
func (d *Datastore) GetLabelSpecs() ([]*fleet.LabelSpec, error) {
|
||||
var specs []*fleet.LabelSpec
|
||||
// Get basic specs
|
||||
query := "SELECT name, description, query, platform, label_type, label_membership_type FROM labels"
|
||||
query := "SELECT id, name, description, query, platform, label_type, label_membership_type FROM labels"
|
||||
if err := d.db.Select(&specs, query); err != nil {
|
||||
return nil, errors.Wrap(err, "get labels")
|
||||
}
|
||||
|
|
|
|||
|
|
@ -190,7 +190,7 @@ type LabelQueryExecution struct {
|
|||
}
|
||||
|
||||
type LabelSpec struct {
|
||||
ID uint
|
||||
ID uint `json:"id"`
|
||||
Name string `json:"name"`
|
||||
Description string `json:"description"`
|
||||
Query string `json:"query"`
|
||||
|
|
|
|||
Loading…
Reference in a new issue