(t *testing.T)
| 568 | } |
| 569 | |
| 570 | func TestLoadWithEnvironmentInterpolation(t *testing.T) { |
| 571 | home := "/home/foo" |
| 572 | config, err := loadYAMLWithEnv(` |
| 573 | version: "3" |
| 574 | services: |
| 575 | test: |
| 576 | image: busybox |
| 577 | labels: |
| 578 | - home1=$HOME |
| 579 | - home2=${HOME} |
| 580 | - nonexistent=$NONEXISTENT |
| 581 | - default=${NONEXISTENT-default} |
| 582 | networks: |
| 583 | test: |
| 584 | driver: $HOME |
| 585 | volumes: |
| 586 | test: |
| 587 | driver: $HOME |
| 588 | `, map[string]string{ |
| 589 | "HOME": home, |
| 590 | "FOO": "foo", |
| 591 | }) |
| 592 | |
| 593 | assert.NilError(t, err) |
| 594 | |
| 595 | expectedLabels := types.Labels{ |
| 596 | "home1": home, |
| 597 | "home2": home, |
| 598 | "nonexistent": "", |
| 599 | "default": "default", |
| 600 | } |
| 601 | |
| 602 | assert.Check(t, is.DeepEqual(expectedLabels, config.Services[0].Labels)) |
| 603 | assert.Check(t, is.Equal(home, config.Networks["test"].Driver)) |
| 604 | assert.Check(t, is.Equal(home, config.Volumes["test"].Driver)) |
| 605 | } |
| 606 | |
| 607 | func TestLoadWithInterpolationCastFull(t *testing.T) { |
| 608 | dict, err := ParseYAML([]byte(` |
nothing calls this directly
no test coverage detected
searching dependent graphs…