TestReconcileVolumes_DivergedIsIgnored verifies that a diverged volume produces no plan operations: recreation of diverged volumes is owned by ensureProjectVolumes (which prompts the user) and runs before reconcile, so the reconciler must not duplicate that decision.
(t *testing.T)
| 284 | // ensureProjectVolumes (which prompts the user) and runs before reconcile, |
| 285 | // so the reconciler must not duplicate that decision. |
| 286 | func TestReconcileVolumes_DivergedIsIgnored(t *testing.T) { |
| 287 | vol := types.VolumeConfig{Name: "myproject_data", Driver: "local"} |
| 288 | |
| 289 | project := &types.Project{ |
| 290 | Name: "myproject", |
| 291 | Volumes: types.Volumes{"data": {Name: "myproject_data", Driver: "local"}}, |
| 292 | Services: types.Services{ |
| 293 | "db": { |
| 294 | Name: "db", |
| 295 | Scale: intPtr(1), |
| 296 | Volumes: []types.ServiceVolumeConfig{ |
| 297 | {Source: "data", Type: "volume"}, |
| 298 | }, |
| 299 | }, |
| 300 | }, |
| 301 | } |
| 302 | observed := &ObservedState{ |
| 303 | ProjectName: "myproject", |
| 304 | Containers: map[string][]ObservedContainer{ |
| 305 | "db": {{ |
| 306 | ID: "c1", Number: 1, State: container.StateRunning, |
| 307 | ConfigHash: mustServiceHash(t, project.Services["db"]), |
| 308 | Summary: container.Summary{ |
| 309 | ID: "c1", |
| 310 | State: container.StateRunning, |
| 311 | Labels: map[string]string{ |
| 312 | api.ServiceLabel: "db", |
| 313 | api.ContainerNumberLabel: "1", |
| 314 | api.ConfigHashLabel: mustServiceHash(t, project.Services["db"]), |
| 315 | }, |
| 316 | Mounts: []container.MountPoint{{Type: "volume", Name: vol.Name}}, |
| 317 | }, |
| 318 | }}, |
| 319 | }, |
| 320 | Networks: map[string]ObservedNetwork{}, |
| 321 | Volumes: map[string]ObservedVolume{ |
| 322 | "data": {Name: vol.Name, ConfigHash: "oldhash"}, |
| 323 | }, |
| 324 | } |
| 325 | |
| 326 | plan, err := reconcile(t.Context(), project, observed, defaultReconcileOptions(), noPrompt) |
| 327 | assert.NilError(t, err) |
| 328 | assert.Assert(t, plan.IsEmpty()) |
| 329 | } |
| 330 | |
| 331 | // --- Container tests --- |
| 332 |
nothing calls this directly
no test coverage detected