MCPcopy Index your code
hub / github.com/docker/cli / TestCreateFilter

Function TestCreateFilter

cli/command/service/ps_test.go:16–43  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

14)
15
16func 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
45func TestCreateFilterWithAmbiguousIDPrefixError(t *testing.T) {
46 apiClient := &fakeClient{

Callers

nothing calls this directly

Calls 3

SetMethod · 0.95
newServiceFunction · 0.85
createFilterFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…