Commit 3b83419b authored by Martin Schurz's avatar Martin Schurz
Browse files

fix: add tests for empty lines in templates

parent 3d86d792
Loading
Loading
Loading
Loading
+22 −0
Original line number Diff line number Diff line
@@ -91,6 +91,8 @@ func TestCronjobMeta(t *testing.T) {
				return
			}

			require.NotRegexp(t, regexp.MustCompile("\n[[:space:]]*\n"), output, "found empty lines in output")

			var cronjobs batchV1beta1.CronJobList
			helm.UnmarshalK8SYaml(t, output, &cronjobs)

@@ -173,6 +175,8 @@ func TestCronjobSchedule(t *testing.T) {
				return
			}

			require.NotRegexp(t, regexp.MustCompile("\n[[:space:]]*\n"), output, "found empty lines in output")

			var cronjobs batchV1beta1.CronJobList
			helm.UnmarshalK8SYaml(t, output, &cronjobs)

@@ -236,6 +240,8 @@ func TestCronjobImage(t *testing.T) {
				return
			}

			require.NotRegexp(t, regexp.MustCompile("\n[[:space:]]*\n"), output, "found empty lines in output")

			var cronjobs batchV1beta1.CronJobList
			helm.UnmarshalK8SYaml(t, output, &cronjobs)

@@ -376,6 +382,8 @@ func TestCronjobLivenessAndReadiness(t *testing.T) {
				return
			}

			require.NotRegexp(t, regexp.MustCompile("\n[[:space:]]*\n"), output, "found empty lines in output")

			var cronjobs batchV1beta1.CronJobList
			helm.UnmarshalK8SYaml(t, output, &cronjobs)

@@ -442,6 +450,8 @@ func TestCronjobNodeSelector(t *testing.T) {
				return
			}

			require.NotRegexp(t, regexp.MustCompile("\n[[:space:]]*\n"), output, "found empty lines in output")

			var cronjobs batchV1beta1.CronJobList
			helm.UnmarshalK8SYaml(t, output, &cronjobs)

@@ -531,6 +541,8 @@ func TestCronjobTolerations(t *testing.T) {
				return
			}

			require.NotRegexp(t, regexp.MustCompile("\n[[:space:]]*\n"), output, "found empty lines in output")

			var cronjobs batchV1beta1.CronJobList
			helm.UnmarshalK8SYaml(t, output, &cronjobs)

@@ -703,6 +715,8 @@ func TestCronjobTemplateWithVolumeMounts(t *testing.T) {
				return
			}

			require.NotRegexp(t, regexp.MustCompile("\n[[:space:]]*\n"), output, "found empty lines in output")

			var cronjobs batchV1beta1.CronJobList
			helm.UnmarshalK8SYaml(t, output, &cronjobs)

@@ -817,6 +831,8 @@ func TestCronjobAffinity(t *testing.T) {
				return
			}

			require.NotRegexp(t, regexp.MustCompile("\n[[:space:]]*\n"), output, "found empty lines in output")

			var cronjobs batchV1beta1.CronJobList
			helm.UnmarshalK8SYaml(t, output, &cronjobs)

@@ -893,6 +909,8 @@ func TestCronJobTemplateWithExtraEnvFrom(t *testing.T) {
				return
			}

			require.NotRegexp(t, regexp.MustCompile("\n[[:space:]]*\n"), output, "found empty lines in output")

			var cronjobs batchV1beta1.CronJobList
			helm.UnmarshalK8SYaml(t, output, &cronjobs)
			for _, cronjob := range cronjobs.Items {
@@ -932,6 +950,8 @@ func TestCronJobTemplateWithSecurityContext(t *testing.T) {
				return
			}

			require.NotRegexp(t, regexp.MustCompile("\n[[:space:]]*\n"), output, "found empty lines in output")

			var cronjobs batchV1beta1.CronJobList
			helm.UnmarshalK8SYaml(t, output, &cronjobs)
			for _, cronjob := range cronjobs.Items {
@@ -973,6 +993,8 @@ func TestCronJobTemplateWithContainerSecurityContext(t *testing.T) {
				return
			}

			require.NotRegexp(t, regexp.MustCompile("\n[[:space:]]*\n"), output, "found empty lines in output")

			var cronjobs batchV1beta1.CronJobList
			helm.UnmarshalK8SYaml(t, output, &cronjobs)
			for _, cronjob := range cronjobs.Items {
+3 −0
Original line number Diff line number Diff line
package main

import (
	"regexp"
	"strings"
	"testing"

@@ -57,6 +58,8 @@ func TestCustomResource(t *testing.T) {
				return
			}

			require.NotRegexp(t, regexp.MustCompile("\n[[:space:]]*\n"), output, "found empty lines in output")

			var renderedObjects []*unstructured.Unstructured
			helm.UnmarshalK8SYaml(t, output, &renderedObjects)

+3 −0
Original line number Diff line number Diff line
package main

import (
	"regexp"
	"strings"
	"testing"

@@ -63,6 +64,8 @@ func TestInitializeDatabaseUrlEnvironmentVariable(t *testing.T) {
				return
			}

			require.NotRegexp(t, regexp.MustCompile("\n[[:space:]]*\n"), output, "found empty lines in output")

			deployment := new(appsV1.Deployment)
			helm.UnmarshalK8SYaml(t, output, &deployment)

+3 −0
Original line number Diff line number Diff line
package main

import (
	"regexp"
	"strings"
	"testing"

@@ -63,6 +64,8 @@ func TestMigrateDatabaseUrlEnvironmentVariable(t *testing.T) {
				return
			}

			require.NotRegexp(t, regexp.MustCompile("\n[[:space:]]*\n"), output, "found empty lines in output")

			deployment := new(appsV1.Deployment)
			helm.UnmarshalK8SYaml(t, output, &deployment)

+16 −0
Original line number Diff line number Diff line
@@ -100,6 +100,8 @@ func TestDeploymentTemplate(t *testing.T) {
				return
			}

			require.NotRegexp(t, regexp.MustCompile("\n[[:space:]]*\n"), output, "found empty lines in output")

			var deployment appsV1.Deployment
			helm.UnmarshalK8SYaml(t, output, &deployment)

@@ -1251,6 +1253,8 @@ func TestServiceExtraPortServicePortDefinition(t *testing.T) {
				return
			}

			require.NotRegexp(t, regexp.MustCompile("\n[[:space:]]*\n"), output, "found empty lines in output")

			deployment := new(appsV1.Deployment)
			helm.UnmarshalK8SYaml(t, output, deployment)
			require.Equal(t, tc.expectedPorts, deployment.Spec.Template.Spec.Containers[0].Ports)
@@ -1413,6 +1417,8 @@ func TestDeploymentTemplateWithVolumeMounts(t *testing.T) {
				return
			}

			require.NotRegexp(t, regexp.MustCompile("\n[[:space:]]*\n"), output, "found empty lines in output")

			deployment := new(appsV1.Deployment)
			helm.UnmarshalK8SYaml(t, output, deployment)

@@ -1489,6 +1495,8 @@ func TestDeploymentDatabaseUrlEnvironmentVariable(t *testing.T) {
				return
			}

			require.NotRegexp(t, regexp.MustCompile("\n[[:space:]]*\n"), output, "found empty lines in output")

			deployment := new(appsV1.Deployment)
			helm.UnmarshalK8SYaml(t, output, &deployment)

@@ -1566,6 +1574,8 @@ func TestDeploymentTemplateWithExtraEnvFrom(t *testing.T) {
				return
			}

			require.NotRegexp(t, regexp.MustCompile("\n[[:space:]]*\n"), output, "found empty lines in output")

			deployment := new(appsV1.Deployment)
			helm.UnmarshalK8SYaml(t, output, deployment)
			require.Contains(t, deployment.Spec.Template.Spec.Containers[0].EnvFrom, tc.expectedEnvFrom)
@@ -1607,6 +1617,8 @@ func TestDeploymentTemplateWithExtraEnv(t *testing.T) {
				return
			}

			require.NotRegexp(t, regexp.MustCompile("\n[[:space:]]*\n"), output, "found empty lines in output")

			deployment := new(appsV1.Deployment)
			helm.UnmarshalK8SYaml(t, output, deployment)
			require.Contains(t, deployment.Spec.Template.Spec.Containers[0].Env, tc.expectedEnv)
@@ -1644,6 +1656,8 @@ func TestDeploymentTemplateWithSecurityContext(t *testing.T) {
				return
			}

			require.NotRegexp(t, regexp.MustCompile("\n[[:space:]]*\n"), output, "found empty lines in output")

			deployment := new(appsV1.Deployment)

			helm.UnmarshalK8SYaml(t, output, deployment)
@@ -1684,6 +1698,8 @@ func TestDeploymentTemplateWithContainerSecurityContext(t *testing.T) {
				return
			}

			require.NotRegexp(t, regexp.MustCompile("\n[[:space:]]*\n"), output, "found empty lines in output")

			deployment := new(appsV1.Deployment)

			helm.UnmarshalK8SYaml(t, output, deployment)
Loading