(t *testing.T)
| 446 | } |
| 447 | |
| 448 | func TestReconcileContainers_ScaleDown(t *testing.T) { |
| 449 | svc := types.ServiceConfig{Name: "web", Scale: intPtr(1)} |
| 450 | hash := mustServiceHash(t, svc) |
| 451 | |
| 452 | project := &types.Project{ |
| 453 | Name: "myproject", |
| 454 | Services: types.Services{"web": svc}, |
| 455 | } |
| 456 | observed := &ObservedState{ |
| 457 | ProjectName: "myproject", |
| 458 | Containers: map[string][]ObservedContainer{ |
| 459 | "web": { |
| 460 | { |
| 461 | ID: "c1", Number: 1, State: container.StateRunning, ConfigHash: hash, |
| 462 | Summary: container.Summary{ |
| 463 | ID: "c1", State: container.StateRunning, |
| 464 | Labels: map[string]string{api.ServiceLabel: "web", api.ContainerNumberLabel: "1", api.ConfigHashLabel: hash}, |
| 465 | }, |
| 466 | }, |
| 467 | { |
| 468 | ID: "c2", Number: 2, State: container.StateRunning, ConfigHash: hash, |
| 469 | Summary: container.Summary{ |
| 470 | ID: "c2", State: container.StateRunning, |
| 471 | Labels: map[string]string{api.ServiceLabel: "web", api.ContainerNumberLabel: "2", api.ConfigHashLabel: hash}, |
| 472 | }, |
| 473 | }, |
| 474 | }, |
| 475 | }, |
| 476 | Networks: map[string]ObservedNetwork{}, |
| 477 | Volumes: map[string]ObservedVolume{}, |
| 478 | } |
| 479 | |
| 480 | plan, err := reconcile(t.Context(), project, observed, defaultReconcileOptions(), noPrompt) |
| 481 | assert.NilError(t, err) |
| 482 | |
| 483 | assert.Equal(t, plan.String(), strings.TrimSpace(` |
| 484 | [] -> #1 service:web:2, StopContainer, scale down |
| 485 | [1] -> #2 service:web:2, RemoveContainer, scale down |
| 486 | `)+"\n") |
| 487 | } |
| 488 | |
| 489 | func TestReconcileContainers_ForceRecreate(t *testing.T) { |
| 490 | svc := types.ServiceConfig{Name: "web", Scale: intPtr(1)} |
nothing calls this directly
no test coverage detected