Modify tests to present expected data in unsorted order.

Modify all `build` tests to use the raw,
non-sorted output of build.  This makes every test
provide coverage for how kustomize re-orders (or
doesn't reorder) resources during processing.

Going forward, the ordering of resources in
_expected_ output should match the depth-first
ordering specified in the `resources:` field used
in the test's kustomization file.

The only exception to this rule would be tests
that actually confirmed some other output
ordering, e.g. the test of the
`LegacyOrderTransformer` plugin.

Fixes #756
Related #821
This commit is contained in:
Jeffrey Regan
2019-06-17 14:41:43 -07:00
parent ed21e77fb1
commit 0b555e1b2c
21 changed files with 613 additions and 582 deletions

View File

@@ -20,7 +20,6 @@ import (
"sigs.k8s.io/kustomize/pkg/target"
"sigs.k8s.io/kustomize/pkg/transformers/config/defaultconfig"
"sigs.k8s.io/kustomize/pkg/types"
"sigs.k8s.io/kustomize/plugin/builtin"
)
// KustTestHarness helps test kustomization generation and transformation.
@@ -190,16 +189,6 @@ func hint(a, b string) string {
func (th *KustTestHarness) AssertActualEqualsExpected(
m resmap.ResMap, expected string) {
th.assertActualEqualsExpected(m, expected, true)
}
func (th *KustTestHarness) AssertActualEqualsExpectedNoSort(
m resmap.ResMap, expected string) {
th.assertActualEqualsExpected(m, expected, false)
}
func (th *KustTestHarness) assertActualEqualsExpected(
m resmap.ResMap, expected string, doLegacySort bool) {
if m == nil {
th.t.Fatalf("Map should not be nil.")
}
@@ -208,9 +197,6 @@ func (th *KustTestHarness) assertActualEqualsExpected(
if len(expected) > 0 && expected[0] == 10 {
expected = expected[1:]
}
if doLegacySort {
builtin.NewLegacyOrderTransformerPlugin().Transform(m)
}
actual, err := m.AsYaml()
if err != nil {
th.t.Fatalf("Unexpected err: %v", err)