diff --git a/pkg/lint/rules/template_test.go b/pkg/lint/rules/template_test.go index 31b031ac6..0099acedf 100644 --- a/pkg/lint/rules/template_test.go +++ b/pkg/lint/rules/template_test.go @@ -25,11 +25,7 @@ import ( "k8s.io/helm/pkg/lint/support" ) -const ( - albatrossTestBasedir = "./testdata/albatross" - badSchemaTestBasedir = "./testdata/badschema" - goodSchemaTestBasedir = "./testdata/goodschema" -) +const templateTestBasedir = "./testdata/albatross" func TestValidateAllowedExtension(t *testing.T) { var failTest = []string{"/foo", "/test.yml", "/test.toml", "test.yml"} @@ -49,7 +45,7 @@ func TestValidateAllowedExtension(t *testing.T) { } func TestTemplateParsing(t *testing.T) { - linter := support.Linter{ChartDir: albatrossTestBasedir} + linter := support.Linter{ChartDir: templateTestBasedir} Templates(&linter) res := linter.Messages @@ -62,8 +58,8 @@ func TestTemplateParsing(t *testing.T) { } } -var wrongTemplatePath = filepath.Join(albatrossTestBasedir, "templates", "fail.yaml") -var ignoredTemplatePath = filepath.Join(albatrossTestBasedir, "fail.yaml.ignored") +var wrongTemplatePath = filepath.Join(templateTestBasedir, "templates", "fail.yaml") +var ignoredTemplatePath = filepath.Join(templateTestBasedir, "fail.yaml.ignored") // Test a template with all the existing features: // namespaces, partial templates @@ -72,35 +68,12 @@ func TestTemplateIntegrationHappyPath(t *testing.T) { os.Rename(wrongTemplatePath, ignoredTemplatePath) defer os.Rename(ignoredTemplatePath, wrongTemplatePath) - linter := support.Linter{ChartDir: albatrossTestBasedir} - Templates(&linter) - res := linter.Messages - - if len(res) != 0 { - t.Fatalf("Expected no error, got %d, %v", len(res), res) - } -} - -func TestBadSchema(t *testing.T) { - linter := support.Linter{ChartDir: badSchemaTestBasedir} - Templates(&linter) - res := linter.Messages - - if len(res) != 1 { - t.Fatalf("Expected two error, got %d, %v", len(res), res) - } - - if !strings.Contains(res[0].Err.Error(), "schema validation failure") { - t.Errorf("Unexpected error: %s", res[0]) - } -} - -func TestGoodSchema(t *testing.T) { - linter := support.Linter{ChartDir: goodSchemaTestBasedir} + linter := support.Linter{ChartDir: templateTestBasedir} Templates(&linter) res := linter.Messages - if len(res) != 0 { - t.Fatalf("Expected no error, got %d, %v", len(res), res) + // expect no errors and one warning indicating no server is available + if len(res) != 1 && linter.Messages[0].Severity != support.WarningSev { + t.Fatalf("Expected one warning and no error, got %d, %v", len(res), res) } } diff --git a/pkg/lint/rules/testdata/badschema/Chart.yaml b/pkg/lint/rules/testdata/badschema/Chart.yaml deleted file mode 100644 index 7aa7c1cf7..000000000 --- a/pkg/lint/rules/testdata/badschema/Chart.yaml +++ /dev/null @@ -1,4 +0,0 @@ -apiVersion: v1 -description: A Helm chart for Kubernetes -name: badschema -version: 0.1.0 diff --git a/pkg/lint/rules/testdata/badschema/templates/pod.yaml b/pkg/lint/rules/testdata/badschema/templates/pod.yaml deleted file mode 100644 index 4fdb41a9e..000000000 --- a/pkg/lint/rules/testdata/badschema/templates/pod.yaml +++ /dev/null @@ -1,10 +0,0 @@ -apiVersion: v1 -kind: Pod -metadata: - name: pod-example -spec: - aaa: zzz - containers: - - image: ubuntu:trusty - command: ["echo"] - args: ["Hello World"] diff --git a/pkg/lint/rules/testdata/badschema/values.yaml b/pkg/lint/rules/testdata/badschema/values.yaml deleted file mode 100644 index ee3400b03..000000000 --- a/pkg/lint/rules/testdata/badschema/values.yaml +++ /dev/null @@ -1,21 +0,0 @@ -# Default values for badpod. -# This is a YAML-formatted file. -# Declare variables to be passed into your templates. -replicaCount: 1 -image: - repository: nginx - tag: stable - pullPolicy: IfNotPresent -service: - name: nginx - type: ClusterIP - externalPort: 80 - internalPort: 80 -resources: - limits: - cpu: 100m - memory: 128Mi - requests: - cpu: 100m - memory: 128Mi - diff --git a/pkg/lint/rules/testdata/goodschema/Chart.yaml b/pkg/lint/rules/testdata/goodschema/Chart.yaml deleted file mode 100644 index 423879419..000000000 --- a/pkg/lint/rules/testdata/goodschema/Chart.yaml +++ /dev/null @@ -1,4 +0,0 @@ -apiVersion: v1 -description: A Helm chart for Kubernetes -name: goodschema -version: 0.1.0 diff --git a/pkg/lint/rules/testdata/goodschema/templates/pod.yaml b/pkg/lint/rules/testdata/goodschema/templates/pod.yaml deleted file mode 100644 index c4599e181..000000000 --- a/pkg/lint/rules/testdata/goodschema/templates/pod.yaml +++ /dev/null @@ -1,10 +0,0 @@ -apiVersion: v1 -kind: Pod -metadata: - name: pod-example -spec: - containers: - - name: pod-example - image: ubuntu:trusty - command: ["echo"] - args: ["Hello World"] diff --git a/pkg/lint/rules/testdata/goodschema/values.yaml b/pkg/lint/rules/testdata/goodschema/values.yaml deleted file mode 100644 index f6d22057e..000000000 --- a/pkg/lint/rules/testdata/goodschema/values.yaml +++ /dev/null @@ -1,21 +0,0 @@ -# Default values for goodpod. -# This is a YAML-formatted file. -# Declare variables to be passed into your templates. -replicaCount: 1 -image: - repository: nginx - tag: stable - pullPolicy: IfNotPresent -service: - name: nginx - type: ClusterIP - externalPort: 80 - internalPort: 80 -resources: - limits: - cpu: 100m - memory: 128Mi - requests: - cpu: 100m - memory: 128Mi -