Documentation ¶
Overview ¶
Package stenciltest contains code for testing templates
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Template ¶
type Template struct {
// contains filtered or unexported fields
}
Template is a template that is being tested by the stenciltest framework.
func (*Template) ErrorContains ¶
ErrorContains denotes that this test run should fail, and the message should contain the provided string.
t.ErrorContains("i am an error")
func (*Template) Ext ¶ added in v1.20.0
func (t *Template) Ext(name string, ext apiv1.Implementation) *Template
Ext registers an in-proc extension with the current stencil template. The stenciltest library does not load the real extensions (because extensions can invoke outbound network calls). It is up to the unit test to provide each extension used by their template with this API. Unit tests can decide if they can use the real implementation of the extension AS IS or if a mock extension is needed to feed fake data per test case.
Note: even though input extension is registered inproc, its response to ExecuteTemplateFunction will be encoded as JSON and decoded back as a plain inteface{} to simulate the GRPC transport layer between stencil and the same extension. Refer to the inprocExt struct docs for details.