MCPcopy
hub / github.com/docker/compose / TestReconcileContainers_ForceRecreate

Function TestReconcileContainers_ForceRecreate

pkg/compose/reconcile_test.go:489–524  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

487}
488
489func TestReconcileContainers_ForceRecreate(t *testing.T) {
490 svc := types.ServiceConfig{Name: "web", Scale: intPtr(1)}
491 hash := mustServiceHash(t, svc)
492
493 project := &types.Project{
494 Name: "myproject",
495 Services: types.Services{"web": svc},
496 }
497 observed := &ObservedState{
498 ProjectName: "myproject",
499 Containers: map[string][]ObservedContainer{
500 "web": {{
501 ID: "c1aabbccddee", Number: 1, State: container.StateRunning, ConfigHash: hash,
502 Summary: container.Summary{
503 ID: "c1aabbccddee", State: container.StateRunning,
504 Labels: map[string]string{api.ServiceLabel: "web", api.ContainerNumberLabel: "1", api.ConfigHashLabel: hash},
505 },
506 }},
507 },
508 Networks: map[string]ObservedNetwork{},
509 Volumes: map[string]ObservedVolume{},
510 }
511
512 opts := defaultReconcileOptions()
513 opts.Recreate = api.RecreateForce
514
515 plan, err := reconcile(t.Context(), project, observed, opts, noPrompt)
516 assert.NilError(t, err)
517
518 assert.Equal(t, plan.String(), strings.TrimSpace(`
519[] -> #1 service:web:1, CreateContainer, config changed (tmpName) [recreate:web:1]
520[1] -> #2 service:web:1, StopContainer, replaced by #1 [recreate:web:1]
521[2] -> #3 service:web:1, RemoveContainer, replaced by #1 [recreate:web:1]
522[3] -> #4 service:web:1, RenameContainer, finalize recreate [recreate:web:1]
523`)+"\n")
524}
525
526func TestReconcileContainers_NeverRecreate(t *testing.T) {
527 project := &types.Project{

Callers

nothing calls this directly

Calls 5

intPtrFunction · 0.85
mustServiceHashFunction · 0.85
defaultReconcileOptionsFunction · 0.85
reconcileFunction · 0.85
StringMethod · 0.45

Tested by

no test coverage detected