2014-03-21 10:35:18 -07:00
|
|
|
package initialize
|
|
|
|
|
|
|
|
import (
|
|
|
|
"os"
|
|
|
|
"testing"
|
|
|
|
)
|
|
|
|
|
|
|
|
func TestEnvironmentApply(t *testing.T) {
|
|
|
|
os.Setenv("COREOS_PUBLIC_IPV4", "192.0.2.3")
|
|
|
|
os.Setenv("COREOS_PRIVATE_IPV4", "192.0.2.203")
|
2014-06-18 11:36:06 -07:00
|
|
|
env := NewEnvironment("./", "./", "./", "", "")
|
2014-03-21 10:35:18 -07:00
|
|
|
input := `[Service]
|
|
|
|
ExecStart=/usr/bin/echo "$public_ipv4"
|
|
|
|
ExecStop=/usr/bin/echo $private_ipv4
|
|
|
|
ExecStop=/usr/bin/echo $unknown
|
|
|
|
`
|
|
|
|
expected := `[Service]
|
|
|
|
ExecStart=/usr/bin/echo "192.0.2.3"
|
|
|
|
ExecStop=/usr/bin/echo 192.0.2.203
|
|
|
|
ExecStop=/usr/bin/echo $unknown
|
|
|
|
`
|
|
|
|
|
|
|
|
output := env.Apply(input)
|
|
|
|
if output != expected {
|
|
|
|
t.Fatalf("Environment incorrectly applied.\nOutput:\n%s\nExpected:\n%s", output, expected)
|
|
|
|
}
|
|
|
|
}
|