open-nomad/api/search_test.go

31 lines
556 B
Go
Raw Normal View History

2017-08-08 21:59:21 +00:00
package api
import (
"testing"
2017-08-10 19:24:11 +00:00
2017-08-11 13:33:00 +00:00
"github.com/hashicorp/nomad/api/contexts"
2017-08-10 19:24:11 +00:00
"github.com/stretchr/testify/assert"
2017-08-08 21:59:21 +00:00
)
2017-08-10 19:24:11 +00:00
func TestSearch_List(t *testing.T) {
2017-08-08 21:59:21 +00:00
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]
2017-08-11 13:33:00 +00:00
resp, err := c.Search().PrefixSearch(prefix, contexts.Jobs)
2017-08-08 21:59:21 +00:00
assert.Nil(err)
jobMatches := resp.Matches[contexts.Jobs]
2017-08-08 21:59:21 +00:00
assert.Equal(1, len(jobMatches))
assert.Equal(id, jobMatches[0])
2017-08-08 21:59:21 +00:00
}