Added support for environment variables to 'templates' module. (#1035)

* * Added support for environment variables to 'templates' module.

* Fixed flaw in test caused by environment variable ordering during testing on CI.

* Updated some local variables to camel-case.

* Reverted changes to replacer as environment variables are processed elsewhere.

* Removed PrintEnv functionality in favour of documenting using template range.
This commit is contained in:
Simon Lightfoot 2016-08-15 18:15:58 +01:00 committed by Matt Holt
parent eb3bbc409f
commit 45ac11088e
3 changed files with 43 additions and 2 deletions

View file

@ -224,6 +224,28 @@ func TestHeader(t *testing.T) {
}
}
func TestEnv(t *testing.T) {
context := getContextOrFail(t)
name := "ENV_TEST_NAME"
testValue := "TEST_VALUE"
os.Setenv(name, testValue)
notExisting := "ENV_TEST_NOT_EXISTING"
os.Unsetenv(notExisting)
env := context.Env()
if value := env[name]; value != testValue {
t.Errorf("Expected env-variable %s value '%s', found '%s'",
name, testValue, value)
}
if value, ok := env[notExisting]; ok {
t.Errorf("Expected empty env-variable %s, found '%s'",
notExisting, value)
}
}
func TestIP(t *testing.T) {
context := getContextOrFail(t)