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

Function TestCreateFromCurrent

cli/command/context/create_test.go:225–273  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

223}
224
225func TestCreateFromCurrent(t *testing.T) {
226 cases := []struct {
227 name string
228 description string
229 orchestrator string
230 expectedDescription string
231 }{
232 {
233 name: "no-override",
234 expectedDescription: "original description",
235 },
236 {
237 name: "override-description",
238 description: "new description",
239 expectedDescription: "new description",
240 },
241 }
242
243 cli := makeFakeCli(t)
244 cli.ResetOutputBuffers()
245 assert.NilError(t, runCreate(cli, "original", createOptions{
246 description: "original description",
247 endpoint: map[string]string{
248 keyHost: "tcp://42.42.42.42:2375",
249 },
250 }))
251 assertContextCreateLogging(t, cli, "original")
252
253 cli.SetCurrentContext("original")
254
255 for _, tc := range cases {
256 t.Run(tc.name, func(t *testing.T) {
257 cli.ResetOutputBuffers()
258 err := runCreate(cli, tc.name, createOptions{
259 description: tc.description,
260 })
261 assert.NilError(t, err)
262 assertContextCreateLogging(t, cli, tc.name)
263 newContext, err := cli.ContextStore().GetMetadata(tc.name)
264 assert.NilError(t, err)
265 newContextTyped, err := command.GetDockerContext(newContext)
266 assert.NilError(t, err)
267 dockerEndpoint, err := docker.EndpointFromContext(newContext)
268 assert.NilError(t, err)
269 assert.Equal(t, newContextTyped.Description, tc.expectedDescription)
270 assert.Equal(t, dockerEndpoint.Host, "tcp://42.42.42.42:2375")
271 })
272 }
273}

Callers

nothing calls this directly

Calls 7

makeFakeCliFunction · 0.85
SetCurrentContextMethod · 0.80
runCreateFunction · 0.70
GetMetadataMethod · 0.65
ContextStoreMethod · 0.65
ResetOutputBuffersMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…