Merge pull request #1561 from beautytiger/dev-190925

improve test code coverage in transformers
This commit is contained in:
Jeff Regan
2019-10-01 12:13:00 -07:00
committed by GitHub

View File

@@ -38,7 +38,11 @@ func TestVarRef(t *testing.T) {
"BOO": true, "BOO": true,
}, },
fs: []config.FieldSpec{ fs: []config.FieldSpec{
{Gvk: gvk.Gvk{Version: "v1", Kind: "ConfigMap"}, Path: "data"}, {Gvk: gvk.Gvk{Version: "v1", Kind: "ConfigMap"}, Path: "data/map"},
{Gvk: gvk.Gvk{Version: "v1", Kind: "ConfigMap"}, Path: "data/slice"},
{Gvk: gvk.Gvk{Version: "v1", Kind: "ConfigMap"}, Path: "data/interface"},
{Gvk: gvk.Gvk{Version: "v1", Kind: "ConfigMap"}, Path: "data/nil"},
{Gvk: gvk.Gvk{Version: "v1", Kind: "ConfigMap"}, Path: "data/num"},
}, },
res: resmaptest_test.NewRmBuilder(t, rf). res: resmaptest_test.NewRmBuilder(t, rf).
Add(map[string]interface{}{ Add(map[string]interface{}{
@@ -48,14 +52,27 @@ func TestVarRef(t *testing.T) {
"name": "cm1", "name": "cm1",
}, },
"data": map[string]interface{}{ "data": map[string]interface{}{
"map": map[string]interface{}{
"item1": "$(FOO)", "item1": "$(FOO)",
"item2": "bla", "item2": "bla",
"item3": "$(BAZ)", "item3": "$(BAZ)",
"item4": "$(BAZ)+$(BAZ)", "item4": "$(BAZ)+$(BAZ)",
"item5": "$(BOO)", "item5": "$(BOO)",
"item6": "if $(BOO)", "item6": "if $(BOO)",
"item7": 2019,
}, },
}).ResMap(), "slice": []interface{}{
"$(FOO)",
"bla",
"$(BAZ)",
"$(BAZ)+$(BAZ)",
"$(BOO)",
"if $(BOO)",
},
"interface": "$(FOO)",
"nil": nil,
"num": 2019,
}}).ResMap(),
}, },
expected: expected{ expected: expected{
res: resmaptest_test.NewRmBuilder(t, rf). res: resmaptest_test.NewRmBuilder(t, rf).
@@ -66,12 +83,26 @@ func TestVarRef(t *testing.T) {
"name": "cm1", "name": "cm1",
}, },
"data": map[string]interface{}{ "data": map[string]interface{}{
"map": map[string]interface{}{
"item1": "replacementForFoo", "item1": "replacementForFoo",
"item2": "bla", "item2": "bla",
"item3": int64(5), "item3": int64(5),
"item4": "5+5", "item4": "5+5",
"item5": true, "item5": true,
"item6": "if true", "item6": "if true",
"item7": 2019,
},
"slice": []interface{}{
"replacementForFoo",
"bla",
int64(5),
"5+5",
true,
"if true",
},
"interface": "replacementForFoo",
"nil": nil,
"num": 2019,
}}).ResMap(), }}).ResMap(),
unused: []string{"BAR"}, unused: []string{"BAR"},
}, },