mirror of
https://github.com/kubernetes-sigs/kustomize.git
synced 2026-06-30 18:01:21 +00:00
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
70 lines
1.1 KiB
Go
70 lines
1.1 KiB
Go
// Copyright 2019 The Kubernetes Authors.
|
|
// SPDX-License-Identifier: Apache-2.0
|
|
|
|
package main_test
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"sigs.k8s.io/kustomize/pkg/kusttest"
|
|
"sigs.k8s.io/kustomize/plugin"
|
|
)
|
|
|
|
func TestPrefixSuffixTransformer(t *testing.T) {
|
|
tc := plugin.NewEnvForTest(t).Set()
|
|
defer tc.Reset()
|
|
|
|
tc.BuildGoPlugin(
|
|
"builtin", "", "PrefixSuffixTransformer")
|
|
|
|
th := kusttest_test.NewKustTestPluginHarness(t, "/app")
|
|
rm := th.LoadAndRunTransformer(`
|
|
apiVersion: builtin
|
|
kind: PrefixSuffixTransformer
|
|
metadata:
|
|
name: notImportantHere
|
|
prefix: baked-
|
|
suffix: -pie
|
|
fieldSpecs:
|
|
- path: metadata/name
|
|
`, `
|
|
apiVersion: v1
|
|
kind: Service
|
|
metadata:
|
|
name: apple
|
|
spec:
|
|
ports:
|
|
- port: 7002
|
|
---
|
|
apiVersion: apiextensions.k8s.io/v1beta1
|
|
kind: CustomResourceDefinition
|
|
metadata:
|
|
name: crd
|
|
---
|
|
apiVersion: v1
|
|
kind: ConfigMap
|
|
metadata:
|
|
name: cm
|
|
`)
|
|
|
|
th.AssertActualEqualsExpected(rm, `
|
|
apiVersion: v1
|
|
kind: Service
|
|
metadata:
|
|
name: baked-apple-pie
|
|
spec:
|
|
ports:
|
|
- port: 7002
|
|
---
|
|
apiVersion: apiextensions.k8s.io/v1beta1
|
|
kind: CustomResourceDefinition
|
|
metadata:
|
|
name: crd
|
|
---
|
|
apiVersion: v1
|
|
kind: ConfigMap
|
|
metadata:
|
|
name: baked-cm-pie
|
|
`)
|
|
}
|