mirror of
https://github.com/yuin/goldmark
synced 2025-03-04 23:04:52 +00:00
Improve the development debugging process by better handling a missing Node Kind RendererFunc. This: panic: runtime error: index out of range [22] with length 20 Becomes: panic: RendererFunc not found for kind: KindName
31 lines
569 B
Go
31 lines
569 B
Go
package renderer_test
|
|
|
|
import (
|
|
"bytes"
|
|
"testing"
|
|
|
|
"github.com/yuin/goldmark/ast"
|
|
"github.com/yuin/goldmark/renderer"
|
|
)
|
|
|
|
type customLink struct {
|
|
ast.Link
|
|
}
|
|
|
|
var kindCustomLink = ast.NewNodeKind("customLink")
|
|
|
|
// Kind implements Node.Kind.
|
|
func (n *customLink) Kind() ast.NodeKind {
|
|
return kindCustomLink
|
|
}
|
|
|
|
func TestMissingRendererFunc(t *testing.T) {
|
|
r := renderer.NewRenderer()
|
|
buf := bytes.NewBuffer([]byte{})
|
|
|
|
err := r.Render(buf, []byte{}, &customLink{})
|
|
if err.Error() != "RendererFunc not found for kind: customLink" {
|
|
t.Log(err)
|
|
t.FailNow()
|
|
}
|
|
}
|