2016-12-21 21:42:39 +00:00
|
|
|
package container
|
2013-01-19 00:13:39 +00:00
|
|
|
|
2015-12-14 10:15:00 +00:00
|
|
|
import "testing"
|
2013-01-19 00:13:39 +00:00
|
|
|
|
2014-03-01 07:29:00 +00:00
|
|
|
func TestReplaceAndAppendEnvVars(t *testing.T) {
|
|
|
|
var (
|
2017-03-08 04:26:02 +00:00
|
|
|
d = []string{"HOME=/", "FOO=foo_default"}
|
|
|
|
// remove FOO from env
|
|
|
|
// remove BAR from env (nop)
|
|
|
|
o = []string{"HOME=/root", "TERM=xterm", "FOO", "BAR"}
|
2014-03-01 07:29:00 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
env := ReplaceOrAppendEnvValues(d, o)
|
2017-03-08 04:26:02 +00:00
|
|
|
t.Logf("default=%v, override=%v, result=%v", d, o, env)
|
2014-03-01 07:29:00 +00:00
|
|
|
if len(env) != 2 {
|
|
|
|
t.Fatalf("expected len of 2 got %d", len(env))
|
|
|
|
}
|
|
|
|
if env[0] != "HOME=/root" {
|
|
|
|
t.Fatalf("expected HOME=/root got '%s'", env[0])
|
|
|
|
}
|
|
|
|
if env[1] != "TERM=xterm" {
|
|
|
|
t.Fatalf("expected TERM=xterm got '%s'", env[1])
|
2015-02-27 02:23:50 +00:00
|
|
|
}
|
|
|
|
}
|