From 69cade143f315be5018354df440899aec83cf8a1 Mon Sep 17 00:00:00 2001 From: monopole Date: Wed, 6 Jan 2021 16:16:20 -0800 Subject: [PATCH] Add test for issue 3424 --- api/krusty/issue3424_test.go | 74 ++++++++++++++++++++++++++++++++++++ 1 file changed, 74 insertions(+) create mode 100644 api/krusty/issue3424_test.go diff --git a/api/krusty/issue3424_test.go b/api/krusty/issue3424_test.go new file mode 100644 index 0000000000..3b3c8cda8d --- /dev/null +++ b/api/krusty/issue3424_test.go @@ -0,0 +1,74 @@ +// Copyright 2020 The Kubernetes Authors. +// SPDX-License-Identifier: Apache-2.0 + +package krusty_test + +import ( + "testing" + + kusttest_test "sigs.k8s.io/kustomize/api/testutils/kusttest" +) + +// Demonstrate unwanted quotes added to an integer by a strategic merge patch. +func TestIssue3424Basics(t *testing.T) { + th := kusttest_test.MakeHarness(t) + th.WriteF("pdb-patch.yaml", ` +apiVersion: policy/v1beta1 +kind: PodDisruptionBudget +metadata: + name: generic-pdb +spec: + maxUnavailable: 1 +`) + th.WriteF("my_file.yaml", ` +apiVersion: policy/v1beta1 +kind: PodDisruptionBudget +metadata: + name: championships-api + labels: + faceit-pdb: default +spec: + maxUnavailable: 100% +--- +apiVersion: policy/v1beta1 +kind: PodDisruptionBudget +metadata: + name: championships-api-2 + labels: + faceit-pdb: default +spec: + maxUnavailable: 100% +`) + th.WriteK(".", ` +apiVersion: kustomize.config.k8s.io/v1beta1 +kind: Kustomization +patches: +- path: pdb-patch.yaml + target: + kind: PodDisruptionBudget + labelSelector: faceit-pdb=default + +resources: +- my_file.yaml +`) + m := th.Run(".", th.MakeDefaultOptions()) + th.AssertActualEqualsExpected(m, ` +apiVersion: policy/v1beta1 +kind: PodDisruptionBudget +metadata: + labels: + faceit-pdb: default + name: championships-api +spec: + maxUnavailable: "1" +--- +apiVersion: policy/v1beta1 +kind: PodDisruptionBudget +metadata: + labels: + faceit-pdb: default + name: championships-api-2 +spec: + maxUnavailable: "1" +`) +}