mirror of
https://github.com/kubernetes-sigs/kustomize.git
synced 2026-05-17 18:25:26 +00:00
Merge pull request #3011 from natasha41575/issue2896test
test for issue 2896
This commit is contained in:
106
api/krusty/issue2896_test.go
Normal file
106
api/krusty/issue2896_test.go
Normal file
@@ -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
|
||||
`)
|
||||
}
|
||||
Reference in New Issue
Block a user