mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-23 19:56:01 +00:00
Moves TestTemplatePanic to correct location of template_test.go
This commit is contained in:
parent
d9ded62fb9
commit
57259fa419
@ -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
|
||||
|
@ -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")
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user