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

Function Test_buildContainerVolumes

pkg/compose/create_test.go:368–486  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

366}
367
368func Test_buildContainerVolumes(t *testing.T) {
369 pwd, err := os.Getwd()
370 assert.NilError(t, err)
371
372 tests := []struct {
373 name string
374 yaml string
375 binds []string
376 mounts []mountTypes.Mount
377 }{
378 {
379 name: "bind mount local path",
380 yaml: `
381services:
382 test:
383 volumes:
384 - ./data:/data
385`,
386 binds: []string{filepath.Join(pwd, "data") + ":/data:rw"},
387 mounts: nil,
388 },
389 {
390 name: "bind mount, not create host path",
391 yaml: `
392services:
393 test:
394 volumes:
395 - type: bind
396 source: ./data
397 target: /data
398 bind:
399 create_host_path: false
400`,
401 binds: nil,
402 mounts: []mountTypes.Mount{
403 {
404 Type: "bind",
405 Source: filepath.Join(pwd, "data"),
406 Target: "/data",
407 BindOptions: &mountTypes.BindOptions{CreateMountpoint: false},
408 },
409 },
410 },
411 {
412 name: "mount volume",
413 yaml: `
414services:
415 test:
416 volumes:
417 - data:/data
418volumes:
419 data:
420 name: my_volume
421`,
422 binds: []string{"my_volume:/data:rw"},
423 mounts: nil,
424 },
425 {

Callers

nothing calls this directly

Calls 1

buildContainerVolumesMethod · 0.95

Tested by

no test coverage detected