Fix TestMapReference needed an ordered mapping
In 405d5d63b1 we changed for an ordered
list to a map, however the test is order dependent go maps are
randomized.
Change the test to use a slice with an internal type (instead of pulling
back in k8s.io/kubernetes).
Without this change this test will fail occasionally and has no
guarentee for success because of the random order of maps.
This commit is contained in:
@@ -5,10 +5,17 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func TestMapReference(t *testing.T) {
|
func TestMapReference(t *testing.T) {
|
||||||
envs := map[string]string{
|
// We use a struct here instead of a map because we need mappings to happen in order.
|
||||||
"FOO": "bar",
|
// Go maps are randomized.
|
||||||
"ZOO": "$(FOO)-1",
|
type envVar struct {
|
||||||
"BLU": "$(ZOO)-2",
|
Name string
|
||||||
|
Value string
|
||||||
|
}
|
||||||
|
|
||||||
|
envs := []envVar{
|
||||||
|
{"FOO", "bar"},
|
||||||
|
{"ZOO", "$(FOO)-1"},
|
||||||
|
{"BLU", "$(ZOO)-2"},
|
||||||
}
|
}
|
||||||
|
|
||||||
declaredEnv := map[string]string{
|
declaredEnv := map[string]string{
|
||||||
@@ -21,8 +28,8 @@ func TestMapReference(t *testing.T) {
|
|||||||
|
|
||||||
mapping := MappingFuncFor(declaredEnv, serviceEnv)
|
mapping := MappingFuncFor(declaredEnv, serviceEnv)
|
||||||
|
|
||||||
for k, v := range envs {
|
for _, env := range envs {
|
||||||
declaredEnv[k] = Expand(v, mapping)
|
declaredEnv[env.Name] = Expand(env.Value, mapping)
|
||||||
}
|
}
|
||||||
|
|
||||||
expectedEnv := map[string]string{
|
expectedEnv := map[string]string{
|
||||||
|
|||||||
Reference in New Issue
Block a user