Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3011 from natasha41575/issue2896test
test for issue 2896
- Loading branch information
Showing
1 changed file
with
106 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,106 @@ | ||
// 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" | ||
) | ||
|
||
func writeIssueBase(th kusttest_test.Harness) { | ||
th.WriteK("base", ` | ||
nameSuffix: -test-api | ||
resources: | ||
- deploy.yaml | ||
`) | ||
th.WriteF("base/deploy.yaml", ` | ||
apiVersion: apps/v1 | ||
kind: Deployment | ||
metadata: | ||
name: example | ||
spec: | ||
template: | ||
spec: | ||
containers: | ||
- name: example | ||
image: example:1.0 | ||
volumeMounts: | ||
- name: conf | ||
mountPath: /etc/config | ||
volumes: | ||
- name: conf | ||
configMap: | ||
name: conf | ||
`) | ||
} | ||
|
||
func TestIssue2896Base(t *testing.T) { | ||
th := kusttest_test.MakeHarness(t) | ||
writeIssueBase(th) | ||
m := th.Run("base", th.MakeDefaultOptions()) | ||
th.AssertActualEqualsExpected(m, ` | ||
apiVersion: apps/v1 | ||
kind: Deployment | ||
metadata: | ||
name: example-test-api | ||
spec: | ||
template: | ||
spec: | ||
containers: | ||
- image: example:1.0 | ||
name: example | ||
volumeMounts: | ||
- mountPath: /etc/config | ||
name: conf | ||
volumes: | ||
- configMap: | ||
name: conf | ||
name: conf | ||
`) | ||
} | ||
|
||
func TestIssue2896Overlay(t *testing.T) { | ||
th := kusttest_test.MakeHarness(t) | ||
writeIssueBase(th) | ||
th.WriteK("overlay", ` | ||
resources: | ||
- ../base | ||
patches: | ||
- patch: |- | ||
apiVersion: apps/v1 | ||
kind: Deployment | ||
metadata: | ||
name: example | ||
spec: | ||
template: | ||
spec: | ||
containers: | ||
- name: example | ||
image: example:2.0 | ||
`) | ||
|
||
m := th.Run("overlay", th.MakeDefaultOptions()) | ||
th.AssertActualEqualsExpected(m, ` | ||
apiVersion: apps/v1 | ||
kind: Deployment | ||
metadata: | ||
name: example | ||
spec: | ||
template: | ||
spec: | ||
containers: | ||
- image: example:2.0 | ||
name: example | ||
volumeMounts: | ||
- mountPath: /etc/config | ||
name: conf | ||
volumes: | ||
- configMap: | ||
name: conf | ||
name: conf | ||
`) | ||
} |