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

Function TestReconcileVolumes_DivergedIsIgnored

pkg/compose/reconcile_test.go:286–329  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

284// ensureProjectVolumes (which prompts the user) and runs before reconcile,
285// so the reconciler must not duplicate that decision.
286func 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

Callers

nothing calls this directly

Calls 5

intPtrFunction · 0.85
mustServiceHashFunction · 0.85
reconcileFunction · 0.85
defaultReconcileOptionsFunction · 0.85
IsEmptyMethod · 0.45

Tested by

no test coverage detected