MCPcopy Index your code
hub / github.com/docker/cli / TestLoadWithEnvironmentInterpolation

Function TestLoadWithEnvironmentInterpolation

cli/compose/loader/loader_test.go:570–605  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

568}
569
570func TestLoadWithEnvironmentInterpolation(t *testing.T) {
571 home := "/home/foo"
572 config, err := loadYAMLWithEnv(`
573version: "3"
574services:
575 test:
576 image: busybox
577 labels:
578 - home1=$HOME
579 - home2=${HOME}
580 - nonexistent=$NONEXISTENT
581 - default=${NONEXISTENT-default}
582networks:
583 test:
584 driver: $HOME
585volumes:
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
607func TestLoadWithInterpolationCastFull(t *testing.T) {
608 dict, err := ParseYAML([]byte(`

Callers

nothing calls this directly

Calls 1

loadYAMLWithEnvFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…