Fixed the client tests

This commit is contained in:
Diptanu Choudhury
2016-07-08 17:42:34 -07:00
parent 29f099cf9d
commit 0769e41982
2 changed files with 12 additions and 7 deletions

View File

@@ -136,11 +136,13 @@ func (t *TaskEnvironment) Build() *TaskEnvironment {
for label, value := range network.MapLabelToValues(nil) {
t.TaskEnv[fmt.Sprintf("%s%s", IpPrefix, label)] = network.IP
t.TaskEnv[fmt.Sprintf("%s%s", HostPortPrefix, label)] = strconv.Itoa(value)
if value, ok := t.PortMap[label]; ok {
t.TaskEnv[fmt.Sprintf("%s%s", PortPrefix, label)] = fmt.Sprintf("%d", value)
IPPort := fmt.Sprintf("%s:%d", network.IP, value)
t.TaskEnv[fmt.Sprintf("%s%s", AddrPrefix, label)] = IPPort
if forwardedPort, ok := t.PortMap[label]; ok {
value = forwardedPort
}
t.TaskEnv[fmt.Sprintf("%s%s", PortPrefix, label)] = fmt.Sprintf("%d", value)
IPPort := fmt.Sprintf("%s:%d", network.IP, value)
t.TaskEnv[fmt.Sprintf("%s%s", AddrPrefix, label)] = IPPort
}
}

View File

@@ -151,7 +151,8 @@ func TestEnvironment_AsList(t *testing.T) {
"NOMAD_ADDR_https=127.0.0.1:443",
"NOMAD_PORT_https=443",
"NOMAD_IP_https=127.0.0.1",
"NOMAD_HOST_PORT_https=443",
"NOMAD_HOST_PORT_http=80",
"NOMAD_HOST_PORT_https=8080",
"NOMAD_META_FOO=baz",
"NOMAD_META_BAZ=bam",
}
@@ -177,7 +178,8 @@ func TestEnvironment_ClearEnvvars(t *testing.T) {
"NOMAD_ADDR_https=127.0.0.1:443",
"NOMAD_PORT_https=443",
"NOMAD_IP_https=127.0.0.1",
"NOMAD_HOST_PORT_https=443",
"NOMAD_HOST_PORT_http=80",
"NOMAD_HOST_PORT_https=8080",
"bar=bang",
"foo=baz",
}
@@ -198,7 +200,8 @@ func TestEnvironment_ClearEnvvars(t *testing.T) {
"NOMAD_ADDR_https=127.0.0.1:443",
"NOMAD_PORT_https=443",
"NOMAD_IP_https=127.0.0.1",
"NOMAD_HOST_PORT_https=443",
"NOMAD_HOST_PORT_https=8080",
"NOMAD_HOST_PORT_http=80",
}
sort.Strings(act)
sort.Strings(exp)