2016-06-23 02:28:45 +08:00
|
|
|
/*
|
|
|
|
Copyright 2016 The Kubernetes Authors All rights reserved.
|
|
|
|
|
|
|
|
Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
you may not use this file except in compliance with the License.
|
|
|
|
You may obtain a copy of the License at
|
|
|
|
|
|
|
|
http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
|
|
|
|
Unless required by applicable law or agreed to in writing, software
|
|
|
|
distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
See the License for the specific language governing permissions and
|
|
|
|
limitations under the License.
|
|
|
|
*/
|
|
|
|
|
2016-06-10 07:51:00 +08:00
|
|
|
package rules
|
2016-04-27 07:20:37 +08:00
|
|
|
|
|
|
|
import (
|
2016-06-10 07:51:00 +08:00
|
|
|
"k8s.io/helm/pkg/lint/support"
|
2016-04-27 07:20:37 +08:00
|
|
|
"strings"
|
|
|
|
"testing"
|
|
|
|
)
|
|
|
|
|
|
|
|
const templateTestBasedir = "./testdata/albatross"
|
|
|
|
|
|
|
|
func TestTemplate(t *testing.T) {
|
2016-06-10 07:51:00 +08:00
|
|
|
linter := support.Linter{ChartDir: templateTestBasedir}
|
|
|
|
Templates(&linter)
|
|
|
|
res := linter.Messages
|
2016-04-27 07:20:37 +08:00
|
|
|
|
|
|
|
if len(res) != 1 {
|
2016-06-10 07:51:00 +08:00
|
|
|
t.Fatalf("Expected one error, got %d, %v", len(res), res)
|
2016-04-27 07:20:37 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
if !strings.Contains(res[0].Text, "deliberateSyntaxError") {
|
|
|
|
t.Errorf("Unexpected error: %s", res[0])
|
|
|
|
}
|
|
|
|
}
|