(t *testing.T)
| 366 | } |
| 367 | |
| 368 | func 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: ` |
| 381 | services: |
| 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: ` |
| 392 | services: |
| 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: ` |
| 414 | services: |
| 415 | test: |
| 416 | volumes: |
| 417 | - data:/data |
| 418 | volumes: |
| 419 | data: |
| 420 | name: my_volume |
| 421 | `, |
| 422 | binds: []string{"my_volume:/data:rw"}, |
| 423 | mounts: nil, |
| 424 | }, |
| 425 | { |
nothing calls this directly
no test coverage detected