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

Function TestResolveService

cli/command/idresolver/idresolver_test.go:118–153  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

116}
117
118func TestResolveService(t *testing.T) {
119 testCases := []struct {
120 serviceID string
121 serviceInspectFunc func(string) (client.ServiceInspectResult, error)
122 expectedID string
123 }{
124 {
125 serviceID: "serviceID",
126 serviceInspectFunc: func(string) (client.ServiceInspectResult, error) {
127 return client.ServiceInspectResult{}, errors.New("error inspecting service")
128 },
129 expectedID: "serviceID",
130 },
131 {
132 serviceID: "serviceID",
133 serviceInspectFunc: func(string) (client.ServiceInspectResult, error) {
134 return client.ServiceInspectResult{
135 Service: *builders.Service(builders.ServiceName("service-foo")),
136 }, nil
137 },
138 expectedID: "service-foo",
139 },
140 }
141
142 ctx := context.Background()
143 for _, tc := range testCases {
144 apiClient := &fakeClient{
145 serviceInspectFunc: tc.serviceInspectFunc,
146 }
147 idResolver := New(apiClient, false)
148 id, err := idResolver.Resolve(ctx, swarm.Service{}, tc.serviceID)
149
150 assert.NilError(t, err)
151 assert.Check(t, is.Equal(tc.expectedID, id))
152 }
153}

Callers

nothing calls this directly

Calls 2

ResolveMethod · 0.80
NewFunction · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…