Commit bfce7266 authored by Martin Schurz's avatar Martin Schurz
Browse files

fix: use yamllint for template tests

parent 3b83419b
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -46,7 +46,7 @@ chart:test:
  variables:
    GO_VERSION: "1.18.6"
  script:
    - apk add build-base
    - apk add build-base yamllint
    - wget https://golang.org/dl/go${GO_VERSION}.linux-amd64.tar.gz
    - tar -C /usr/local -xzf go${GO_VERSION}.linux-amd64.tar.gz
    - export PATH=$PATH:/usr/local/go/bin
+1 −8
Original line number Diff line number Diff line
@@ -84,14 +84,7 @@ func TestCronjobMeta(t *testing.T) {
				KubectlOptions: k8s.NewKubectlOptions("", "", namespaceName),
			}

			output, err := helm.RenderTemplateE(t, options, helmChartPath, tc.Release, []string{"templates/cronjob.yaml"})

			if err != nil {
				t.Error(err)
				return
			}

			require.NotRegexp(t, regexp.MustCompile("\n[[:space:]]*\n"), output, "found empty lines in output")
			output := renderTemplate(t, options, tc.Release, []string{"templates/cronjob.yaml"}, nil)

			var cronjobs batchV1beta1.CronJobList
			helm.UnmarshalK8SYaml(t, output, &cronjobs)
+3 −4
Original line number Diff line number Diff line
@@ -69,11 +69,10 @@ func TestHPA_AutoscalingV1(t *testing.T) {

	for _, tc := range tcs {
		t.Run(tc.name, func(t *testing.T) {
			output, ret := renderTemplate(t, tc.values, releaseName, templates, tc.expectedErrorRegexp)

			if ret == false {
				return
			opts := &helm.Options{
				SetValues:   tc.values,
			}
			output := renderTemplate(t, opts, releaseName, templates, tc.expectedErrorRegexp)

			hpa := new(autoscalingV1.HorizontalPodAutoscaler)
			helm.UnmarshalK8SYaml(t, output, hpa)
+6 −8
Original line number Diff line number Diff line
@@ -112,11 +112,10 @@ func TestIngressTemplate_DifferentTracks(t *testing.T) {

	for _, tc := range tcs {
		t.Run(tc.name, func(t *testing.T) {
			output, ret := renderTemplate(t, tc.values, tc.releaseName, templates, tc.expectedErrorRegexp)

			if ret == false {
				return
			opts := &helm.Options{
				SetValues:   tc.values,
			}
			output := renderTemplate(t, opts, tc.releaseName, templates, tc.expectedErrorRegexp)

			ingress := new(extensions.Ingress)
			helm.UnmarshalK8SYaml(t, output, ingress)
@@ -162,11 +161,10 @@ func TestIngressTemplate_TLS(t *testing.T) {

	for _, tc := range tcs {
		t.Run(tc.name, func(t *testing.T) {
			output, ret := renderTemplate(t, tc.values, releaseName, templates, tc.expectedErrorRegexp)

			if ret == false {
				return
			opts := &helm.Options{
				SetValues:   tc.values,
			}
			output := renderTemplate(t, opts, releaseName, templates, tc.expectedErrorRegexp)

			ingress := new(extensions.Ingress)
			helm.UnmarshalK8SYaml(t, output, ingress)
+6 −8
Original line number Diff line number Diff line
@@ -71,11 +71,10 @@ func TestPvcTemplate_Single(t *testing.T) {

	for _, tc := range tcs {
		t.Run(tc.name, func(t *testing.T) {
			output, ret := renderTemplate(t, tc.values, releaseName, templates, tc.expectedErrorRegexp)

			if ret == false {
				return
			opts := &helm.Options{
				SetValues:   tc.values,
			}
			output := renderTemplate(t, opts, releaseName, templates, tc.expectedErrorRegexp)

			pvc := new(coreV1.PersistentVolumeClaim)
			helm.UnmarshalK8SYaml(t, output, pvc)
@@ -146,11 +145,10 @@ func TestPvcTemplate_Multiple(t *testing.T) {

	for _, tc := range tcs {
		t.Run(tc.name, func(t *testing.T) {
			output, ret := renderTemplate(t, tc.values, releaseName, templates, tc.expectedErrorRegexp)

			if ret == false {
				return
			opts := &helm.Options{
				SetValues:   tc.values,
			}
			output := renderTemplate(t, opts, releaseName, templates, tc.expectedErrorRegexp)

			pvcList := strings.Split(output, "---")
			for i, pvcOutput := range pvcList[1:] {
Loading