From 5f84e6acc2af0190824637f1b5236fc64c56dc7e Mon Sep 17 00:00:00 2001 From: Balazs Nagy Date: Sat, 22 Oct 2022 22:22:51 +0200 Subject: [PATCH] test simple generateName metadata behavior fix issue number --- api/krusty/generatename_test.go | 54 +++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 api/krusty/generatename_test.go diff --git a/api/krusty/generatename_test.go b/api/krusty/generatename_test.go new file mode 100644 index 0000000000..bef7d82ee8 --- /dev/null +++ b/api/krusty/generatename_test.go @@ -0,0 +1,54 @@ +// Copyright 2019 The Kubernetes Authors. +// SPDX-License-Identifier: Apache-2.0 + +package krusty_test + +import ( + "testing" + + kusttest_test "sigs.k8s.io/kustomize/api/testutils/kusttest" +) + +// Coverage for issue #641 +func TestGenerateName(t *testing.T) { + th := kusttest_test.MakeHarness(t) + + th.WriteK(".", ` +resources: +- job.yaml +namePrefix: pre- +nameSuffix: -post +`) + th.WriteF("job.yaml", ` +apiVersion: batch/v1 +kind: Job +metadata: + generateName: job- +spec: + template: + spec: + containers: + - name: job + image: run/job:1.0 + command: + - echo + - done +`) + + m := th.Run(".", th.MakeDefaultOptions()) + th.AssertActualEqualsExpected(m, ` +apiVersion: batch/v1 +kind: Job +metadata: + generateName: job- +spec: + template: + spec: + containers: + - command: + - echo + - done + image: run/job:1.0 + name: job +`) +}