Files
nomad/api/search_test.go
Chelsea Holland Komlo 4edc38d5c2 using contexts constants in replace of string contexts
fix up endpoints
2017-08-14 17:38:10 +00:00

32 lines
588 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, err := c.Search().PrefixSearch(prefix, contexts.Jobs)
assert.Nil(err)
assert.NotEqual(0, resp.Index)
jobMatches := resp.Matches[contexts.Jobs]
assert.Equal(1, len(jobMatches))
assert.Equal(id, jobMatches[0])
}