github.com/ssdev-go/moby@v17.12.1-ce-rc2+incompatible/container/env_test.go (about)

     1  package container
     2  
     3  import "testing"
     4  
     5  func TestReplaceAndAppendEnvVars(t *testing.T) {
     6  	var (
     7  		d = []string{"HOME=/", "FOO=foo_default"}
     8  		// remove FOO from env
     9  		// remove BAR from env (nop)
    10  		o = []string{"HOME=/root", "TERM=xterm", "FOO", "BAR"}
    11  	)
    12  
    13  	env := ReplaceOrAppendEnvValues(d, o)
    14  	t.Logf("default=%v, override=%v, result=%v", d, o, env)
    15  	if len(env) != 2 {
    16  		t.Fatalf("expected len of 2 got %d", len(env))
    17  	}
    18  	if env[0] != "HOME=/root" {
    19  		t.Fatalf("expected HOME=/root got '%s'", env[0])
    20  	}
    21  	if env[1] != "TERM=xterm" {
    22  		t.Fatalf("expected TERM=xterm got '%s'", env[1])
    23  	}
    24  }