From 932663bd5f2c0dd7281160c02b78539c29b6c68b Mon Sep 17 00:00:00 2001 From: vaikas-google Date: Wed, 11 May 2016 16:20:09 -0700 Subject: [PATCH] add test for malformed values.toml file --- pkg/lint/lint_test.go | 13 ++++++++++++- pkg/lint/testdata/badvaluesfile/Chart.yaml | 4 ++++ .../badvaluesfile/templates/badvaluesfile.yaml | 2 ++ pkg/lint/testdata/badvaluesfile/values.toml | 2 ++ 4 files changed, 20 insertions(+), 1 deletion(-) create mode 100644 pkg/lint/testdata/badvaluesfile/Chart.yaml create mode 100644 pkg/lint/testdata/badvaluesfile/templates/badvaluesfile.yaml create mode 100644 pkg/lint/testdata/badvaluesfile/values.toml diff --git a/pkg/lint/lint_test.go b/pkg/lint/lint_test.go index 15831d392..65f4ace7f 100644 --- a/pkg/lint/lint_test.go +++ b/pkg/lint/lint_test.go @@ -7,6 +7,7 @@ import ( ) const badChartDir = "testdata/badchartfile" +const badValuesFileDir = "testdata/badvaluesfile" const badYamlFileDir = "testdata/albatross" const goodChartDir = "testdata/goodone" @@ -40,13 +41,23 @@ func TestBadChart(t *testing.T) { func TestInvalidYaml(t *testing.T) { m := All(badYamlFileDir) if len(m) != 1 { - t.Errorf("All didn't fail with expected errors") + t.Errorf("All didn't fail with expected errors, got %#v", m) } if !strings.Contains(m[0].Text, "deliberateSyntaxError") { t.Errorf("All didn't have the error for deliberateSyntaxError") } } +func TestBadValues(t *testing.T) { + m := All(badValuesFileDir) + if len(m) != 1 { + t.Errorf("All didn't fail with expected errors, got %#v", m) + } + if !strings.Contains(m[0].Text, "Bare keys cannot contain ':'") { + t.Errorf("All didn't have the error for invalid key format") + } +} + func TestGoodChart(t *testing.T) { m := All(goodChartDir) if len(m) != 0 { diff --git a/pkg/lint/testdata/badvaluesfile/Chart.yaml b/pkg/lint/testdata/badvaluesfile/Chart.yaml new file mode 100644 index 000000000..a6ec87d2c --- /dev/null +++ b/pkg/lint/testdata/badvaluesfile/Chart.yaml @@ -0,0 +1,4 @@ +name: badvaluesfile +description: A Helm chart for Kubernetes +version: 0.0.1 +home: "" diff --git a/pkg/lint/testdata/badvaluesfile/templates/badvaluesfile.yaml b/pkg/lint/testdata/badvaluesfile/templates/badvaluesfile.yaml new file mode 100644 index 000000000..6c2ceb8db --- /dev/null +++ b/pkg/lint/testdata/badvaluesfile/templates/badvaluesfile.yaml @@ -0,0 +1,2 @@ +metadata: + name: {{.name | default "foo" | title}} diff --git a/pkg/lint/testdata/badvaluesfile/values.toml b/pkg/lint/testdata/badvaluesfile/values.toml new file mode 100644 index 000000000..80488f4f7 --- /dev/null +++ b/pkg/lint/testdata/badvaluesfile/values.toml @@ -0,0 +1,2 @@ +# Invalid value for badvaluesfile for testing lint fails with invalid toml format +name: "value"