Moves TestTemplatePanic to correct location of template_test.go

This commit is contained in:
Sean Sullivan 2019-10-16 16:28:53 -07:00
parent d9ded62fb9
commit 57259fa419
2 changed files with 16 additions and 16 deletions

View File

@ -202,22 +202,6 @@ func TestPrintHandlerError(t *testing.T) {
}
}
func TestTemplatePanic(t *testing.T) {
tmpl := `{{and ((index .currentState.info "foo").state.running.startedAt) .currentState.info.net.state.running.startedAt}}`
printer, err := genericprinters.NewGoTemplatePrinter([]byte(tmpl))
if err != nil {
t.Fatalf("tmpl fail: %v", err)
}
buffer := &bytes.Buffer{}
err = printer.PrintObj(&v1.Pod{}, buffer)
if err == nil {
t.Fatalf("expected that template to crash")
}
if buffer.String() == "" {
t.Errorf("no debugging info was printed")
}
}
func TestNamePrinter(t *testing.T) {
tests := map[string]struct {
obj runtime.Object

View File

@ -226,3 +226,19 @@ func TestTemplateStrings(t *testing.T) {
}
}
}
func TestTemplatePanic(t *testing.T) {
tmpl := `{{and ((index .currentState.info "foo").state.running.startedAt) .currentState.info.net.state.running.startedAt}}`
printer, err := NewGoTemplatePrinter([]byte(tmpl))
if err != nil {
t.Fatalf("tmpl fail: %v", err)
}
buffer := &bytes.Buffer{}
err = printer.PrintObj(&v1.Pod{}, buffer)
if err == nil {
t.Fatalf("expected that template to crash")
}
if buffer.String() == "" {
t.Errorf("no debugging info was printed")
}
}