(t *testing.T)
| 223 | } |
| 224 | |
| 225 | func 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 | } |
nothing calls this directly
no test coverage detected
searching dependent graphs…