open-nomad/api/search_test.go
Alex Dadgar d7d8661485 Search respects QueryOptions and returns QueryMeta
@chelseakomlo heads up on this change
2017-08-27 22:17:51 -07:00

32 lines
584 B
Go

package api
import (
"testing"
"github.com/hashicorp/nomad/api/contexts"
"github.com/stretchr/testify/assert"
)
func TestSearch_List(t *testing.T) {
assert := assert.New(t)
t.Parallel()
c, s := makeClient(t, nil, nil)
defer s.Stop()
job := testJob()
_, _, err := c.Jobs().Register(job, nil)
assert.Nil(err)
id := *job.ID
prefix := id[:len(id)-2]
resp, qm, err := c.Search().PrefixSearch(prefix, contexts.Jobs, nil)
assert.Nil(err)
assert.NotNil(qm)
jobMatches := resp.Matches[contexts.Jobs]
assert.Equal(1, len(jobMatches))
assert.Equal(id, jobMatches[0])
}