github.com/hspak/nomad@v0.7.2-0.20180309000617-bc4ae22a39a5/api/search_test.go (about) 1 package api 2 3 import ( 4 "testing" 5 6 "github.com/hashicorp/nomad/api/contexts" 7 "github.com/stretchr/testify/assert" 8 ) 9 10 func TestSearch_List(t *testing.T) { 11 assert := assert.New(t) 12 t.Parallel() 13 14 c, s := makeClient(t, nil, nil) 15 defer s.Stop() 16 17 job := testJob() 18 _, _, err := c.Jobs().Register(job, nil) 19 assert.Nil(err) 20 21 id := *job.ID 22 prefix := id[:len(id)-2] 23 resp, qm, err := c.Search().PrefixSearch(prefix, contexts.Jobs, nil) 24 25 assert.Nil(err) 26 assert.NotNil(qm) 27 28 jobMatches := resp.Matches[contexts.Jobs] 29 assert.Equal(1, len(jobMatches)) 30 assert.Equal(id, jobMatches[0]) 31 }