mirror of
https://github.com/kubernetes-sigs/kustomize.git
synced 2026-05-17 18:25:26 +00:00
Add SedTransformerTest
This commit is contained in:
@@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
package builtin
|
||||
package main_test
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
@@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
package builtin
|
||||
package main_test
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
@@ -19,10 +19,9 @@ set -e
|
||||
# and inflates it to stdout, using the given values file.
|
||||
#
|
||||
# chartDir default: $TMP_DIR/charts
|
||||
# chartDir default:
|
||||
|
||||
#
|
||||
# Example execution:
|
||||
# ./plugins/kustomize.config.k8s.io/v1/ChartInflatorExec configFile.yaml
|
||||
# ./plugin/someteam.example.com/v1/ChartInflatorExec configFile.yaml
|
||||
|
||||
|
||||
# Yaml parsing is a ridiculous thing to do in bash,
|
||||
|
||||
65
plugin/someteam.example.com/v1/SedTransformer_test.go
Normal file
65
plugin/someteam.example.com/v1/SedTransformer_test.go
Normal file
@@ -0,0 +1,65 @@
|
||||
/*
|
||||
Copyright 2019 The Kubernetes Authors.
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
package main_test
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"sigs.k8s.io/kustomize/internal/plugintest"
|
||||
"sigs.k8s.io/kustomize/k8sdeps/kv/plugin"
|
||||
"sigs.k8s.io/kustomize/pkg/kusttest"
|
||||
"sigs.k8s.io/kustomize/pkg/loader"
|
||||
)
|
||||
|
||||
func TestSedTransformer(t *testing.T) {
|
||||
tc := plugintest_test.NewPluginTestEnv(t).Set()
|
||||
defer tc.Reset()
|
||||
|
||||
tc.BuildExecPlugin("someteam.example.com", "v1", "SedTransformer")
|
||||
th := kusttest_test.NewKustTestHarnessFull(
|
||||
t, "/app", loader.RestrictionRootOnly, plugin.ActivePluginConfig())
|
||||
|
||||
th.WriteF("/app/sed-input.txt", `
|
||||
s/$FRUIT/orange/g
|
||||
s/$VEGGIE/tomato/g
|
||||
`)
|
||||
|
||||
rm := th.LoadAndRunTransformer(`
|
||||
apiVersion: someteam.example.com/v1
|
||||
kind: SedTransformer
|
||||
metadata:
|
||||
name: notImportantHere
|
||||
argsOneLiner: s/one/two/g
|
||||
argsFromFile: sed-input.txt
|
||||
`,
|
||||
`apiVersion: apps/v1
|
||||
kind: MeatBall
|
||||
metadata:
|
||||
name: notImportantHere
|
||||
beans: one one one one
|
||||
fruit: $FRUIT
|
||||
vegetable: $VEGGIE
|
||||
`)
|
||||
|
||||
th.AssertActualEqualsExpected(rm, `
|
||||
apiVersion: apps/v1
|
||||
beans: two two two two
|
||||
fruit: orange
|
||||
kind: MeatBall
|
||||
metadata:
|
||||
annotations: {}
|
||||
name: notImportantHere
|
||||
vegetable: tomato
|
||||
`)
|
||||
}
|
||||
Reference in New Issue
Block a user