Add test template example for helm create

As helm create ganerates an nginx chart, the example is based on
https://github.com/helm/helm/blob/master/docs/examples/nginx/templates/
service-test.yaml

Signed-off-by: Martin Hickey <martin.hickey@ie.ibm.com>
pull/4524/head
Martin Hickey 7 years ago
parent fbda50a452
commit 2f4d86d94c

@ -143,8 +143,8 @@ func TestCreateStarterCmd(t *testing.T) {
t.Errorf("Wrong API version: %q", c.Metadata.ApiVersion)
}
if l := len(c.Templates); l != 6 {
t.Errorf("Expected 5 templates, got %d", l)
if l := len(c.Templates); l != 7 {
t.Errorf("Expected 6 templates, got %d", l)
}
found := false

@ -44,8 +44,10 @@ const (
ServiceName = "service.yaml"
// NotesName is the name of the example NOTES.txt file.
NotesName = "NOTES.txt"
// HelpersName is the name of the example NOTES.txt file.
// HelpersName is the name of the example helpers file.
HelpersName = "_helpers.tpl"
// ServiceTestName is the name of the example test service file.
ServiceTestName = "service-test.yaml"
)
const defaultValues = `# Default values for %s.
@ -290,6 +292,26 @@ Create chart name and version as used by the chart label.
{{- end -}}
`
const defaultServiceTest = `apiVersion: v1
kind: Pod
metadata:
name: "{{ template "<CHARTNAME>.fullname" . }}-service-test"
labels:
heritage: {{ .Release.Service }}
release: {{ .Release.Name }}
chart: {{ .Chart.Name }}-{{ .Chart.Version }}
app: {{ template "<CHARTNAME>.name" . }}
annotations:
"helm.sh/hook": test-success
spec:
containers:
- name: curl
image: radial/busyboxplus:curl
command: ['curl']
args: ['{{ template "<CHARTNAME>.fullname" . }}:{{ .Values.service.port }}']
restartPolicy: Never
`
// CreateFrom creates a new chart, but scaffolds it from the src chart.
func CreateFrom(chartfile *chart.Metadata, dest string, src string) error {
schart, err := Load(src)
@ -399,6 +421,11 @@ func Create(chartfile *chart.Metadata, dir string) (string, error) {
path: filepath.Join(cdir, TemplatesDir, HelpersName),
content: Transform(defaultHelpers, "<CHARTNAME>", chartfile.Name),
},
{
// service-test.yaml
path: filepath.Join(cdir, TemplatesDir, ServiceTestName),
content: Transform(defaultServiceTest, "<CHARTNAME>", chartfile.Name),
},
}
for _, file := range files {

@ -67,7 +67,7 @@ func TestCreate(t *testing.T) {
}
}
for _, f := range []string{NotesName, DeploymentName, ServiceName, HelpersName} {
for _, f := range []string{NotesName, DeploymentName, ServiceName, HelpersName, ServiceTestName} {
if fi, err := os.Stat(filepath.Join(dir, TemplatesDir, f)); err != nil {
t.Errorf("Expected %s file: %s", f, err)
} else if fi.IsDir() {

Loading…
Cancel
Save