(t *testing.T)
| 14 | ) |
| 15 | |
| 16 | func TestCreateFilter(t *testing.T) { |
| 17 | apiClient := &fakeClient{ |
| 18 | serviceListFunc: func(ctx context.Context, options client.ServiceListOptions) (client.ServiceListResult, error) { |
| 19 | return client.ServiceListResult{ |
| 20 | Items: []swarm.Service{ |
| 21 | {ID: "idmatch"}, |
| 22 | {ID: "idprefixmatch"}, |
| 23 | newService("cccccccc", "namematch"), |
| 24 | newService("01010101", "notfoundprefix"), |
| 25 | }, |
| 26 | }, nil |
| 27 | }, |
| 28 | } |
| 29 | |
| 30 | filter := opts.NewFilterOpt() |
| 31 | assert.NilError(t, filter.Set("node=somenode")) |
| 32 | options := psOptions{ |
| 33 | services: []string{"idmatch", "idprefix", "namematch", "notfound"}, |
| 34 | filter: filter, |
| 35 | } |
| 36 | |
| 37 | actual, notfound, err := createFilter(context.Background(), apiClient, options) |
| 38 | assert.NilError(t, err) |
| 39 | assert.Check(t, is.DeepEqual(notfound, []string{"no such service: notfound"})) |
| 40 | |
| 41 | expected := make(client.Filters).Add("service", "idmatch").Add("service", "idprefixmatch").Add("service", "cccccccc").Add("node", "somenode") |
| 42 | assert.DeepEqual(t, expected, actual) |
| 43 | } |
| 44 | |
| 45 | func TestCreateFilterWithAmbiguousIDPrefixError(t *testing.T) { |
| 46 | apiClient := &fakeClient{ |
nothing calls this directly
no test coverage detected
searching dependent graphs…