add UT for chart with unknown field

Signed-off-by: Zhou Hao <zhouhao@cn.fujitsu.com>
pull/9026/head
Zhou Hao 5 years ago
parent 30cf4d6e6b
commit 769a939f77

@ -201,6 +201,13 @@ func TestInstall(t *testing.T) {
name: "install chart with only crds",
cmd: "install crd-test testdata/testcharts/chart-with-only-crds --namespace default",
},
// Install, chart with unknown field
{
name: "install chart with unknown field",
cmd: "install unknownfield testdata/testcharts/chart-unknown-field",
wantError: true,
golden: "output/install-chart-unknown-field.txt",
},
}
runTestActionCmd(t, tests)

@ -121,6 +121,12 @@ func TestTemplateCmd(t *testing.T) {
wantError: true,
golden: "output/template-with-invalid-yaml-debug.txt",
},
{
name: "chart with template with unknown field",
cmd: fmt.Sprintf("template '%s' --validate --output-dir '%s'", "testdata/testcharts/chart-unknown-field", "output/dump"),
wantError: true,
golden: "output/template-chart-unknown-field.txt",
},
}
runTestCmd(t, tests)
}

@ -0,0 +1 @@
Error: unable to build kubernetes objects from release manifest: error validating "": error validating data: ValidationError(Pod.spec): unknown field "invalidKey" in io.k8s.api.core.v1.PodSpec

@ -0,0 +1,2 @@
wrote output/dump/alpine/templates/alpine-pod.yaml
Error: unable to build kubernetes objects from release manifest: error validating "": error validating data: ValidationError(Pod.spec): unknown field "invalidKey" in io.k8s.api.core.v1.PodSpec

@ -0,0 +1,8 @@
apiVersion: v1
appVersion: "3.9"
description: Deploy a basic Alpine Linux pod
home: https://helm.sh/helm
name: alpine
sources:
- https://github.com/helm/helm
version: 0.1.0

@ -0,0 +1,13 @@
# Alpine: A simple Helm chart
Run a single pod of Alpine Linux.
This example was generated using the command `helm create alpine`.
The `templates/` directory contains a very simple pod resource with a
couple of parameters.
The `values.yaml` file contains the default values for the
`alpine-pod.yaml` template.
You can install this example using `helm install ./alpine`.

@ -0,0 +1,28 @@
apiVersion: v1
kind: Pod
metadata:
name: "{{.Release.Name}}-{{.Values.Name}}"
labels:
# The "app.kubernetes.io/managed-by" label is used to track which tool
# deployed a given chart. It is useful for admins who want to see what
# releases a particular tool is responsible for.
app.kubernetes.io/managed-by: {{.Release.Service | quote }}
# The "app.kubernetes.io/instance" convention makes it easy to tie a release
# to all of the Kubernetes resources that were created as part of that
# release.
app.kubernetes.io/instance: {{.Release.Name | quote }}
app.kubernetes.io/version: {{ .Chart.AppVersion }}
# This makes it easy to audit chart usage.
helm.sh/chart: "{{.Chart.Name}}-{{.Chart.Version}}"
values: {{.Values.Name}}
spec:
# This shows how to use a simple value. This will look for a passed-in value
# called restartPolicy. If it is not found, it will use the default value.
# {{default "Never" .restartPolicy}} is a slightly optimized version of the
# more conventional syntax: {{.restartPolicy | default "Never"}}
restartPolicy: {{default "Never" .Values.restartPolicy}}
containers:
- name: waiter
image: "alpine:{{ .Chart.AppVersion }}"
command: ["/bin/sleep","9000"]
invalidKey: invalidValue
Loading…
Cancel
Save