2020-12-15 02:13:34 +00:00
|
|
|
package service
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
"testing"
|
|
|
|
|
2021-06-06 22:07:29 +00:00
|
|
|
"github.com/fleetdm/fleet/server/fleet"
|
2020-12-15 02:13:34 +00:00
|
|
|
"github.com/fleetdm/fleet/server/mock"
|
|
|
|
"github.com/stretchr/testify/require"
|
|
|
|
)
|
|
|
|
|
|
|
|
func TestNewQueryAttach(t *testing.T) {
|
|
|
|
ds := new(mock.Store)
|
2021-06-03 23:24:15 +00:00
|
|
|
svc := newTestService(ds, nil, nil)
|
2020-12-15 02:13:34 +00:00
|
|
|
|
|
|
|
name := "bad"
|
|
|
|
query := "attach '/nope' as bad"
|
2021-06-03 23:24:15 +00:00
|
|
|
_, err := svc.NewQuery(
|
2020-12-15 02:13:34 +00:00
|
|
|
context.Background(),
|
2021-06-06 22:07:29 +00:00
|
|
|
fleet.QueryPayload{Name: &name, Query: &query},
|
2020-12-15 02:13:34 +00:00
|
|
|
)
|
|
|
|
require.Error(t, err)
|
|
|
|
}
|