mirror of
https://github.com/kemko/nomad.git
synced 2026-01-06 18:35:44 +03:00
using contexts constants in replace of string contexts
fix up endpoints
This commit is contained in:
@@ -1,11 +1,12 @@
|
||||
package contexts
|
||||
|
||||
// Context is a type which is searchable via a unique identifier.
|
||||
type Context string
|
||||
|
||||
const (
|
||||
Alloc Context = "allocs"
|
||||
Eval Context = "evals"
|
||||
Job Context = "jobs"
|
||||
Node Context = "nodes"
|
||||
All Context = ""
|
||||
Allocs Context = "allocs"
|
||||
Evals Context = "evals"
|
||||
Jobs Context = "jobs"
|
||||
Nodes Context = "nodes"
|
||||
All Context = ""
|
||||
)
|
||||
|
||||
@@ -18,7 +18,7 @@ func (c *Client) Search() *Search {
|
||||
// context is not specified, matches for all contexts are returned.
|
||||
func (s *Search) PrefixSearch(prefix string, context c.Context) (*structs.SearchResponse, error) {
|
||||
var resp structs.SearchResponse
|
||||
req := &structs.SearchRequest{Prefix: prefix, Context: string(context)}
|
||||
req := &structs.SearchRequest{Prefix: prefix, Context: context}
|
||||
|
||||
_, err := s.client.write("/v1/search", req, &resp, nil)
|
||||
if err != nil {
|
||||
|
||||
@@ -25,7 +25,7 @@ func TestSearch_List(t *testing.T) {
|
||||
assert.Nil(err)
|
||||
assert.NotEqual(0, resp.Index)
|
||||
|
||||
jobMatches := resp.Matches[contexts.jobs]
|
||||
jobMatches := resp.Matches[contexts.Jobs]
|
||||
assert.Equal(1, len(jobMatches))
|
||||
assert.Equal(id, jobMatches[0])
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user