Documentation
¶
Overview ¶
Package uitest provides a mock implementation of gas.UIProvider for use in tests. The mock records all calls and allows configuring per-method behavior via function fields.
mock := &uitest.MockUI{}
mock.RenderFn = func(w http.ResponseWriter, name string, data any) error {
w.Write([]byte("<h1>Hello</h1>"))
return nil
}
Index ¶
- type Call
- type MockUI
- func (m *MockUI) CallCount(method string) int
- func (m *MockUI) RegisterFuncs(funcs template.FuncMap)
- func (m *MockUI) Render(w http.ResponseWriter, name string, data any) error
- func (m *MockUI) RenderFragment(w http.ResponseWriter, name string, data any) error
- func (m *MockUI) RenderWithStatus(w http.ResponseWriter, status int, name string, data any) error
- func (m *MockUI) Reset()
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type MockUI ¶
type MockUI struct {
RenderFn func(w http.ResponseWriter, name string, data any) error
RenderFragmentFn func(w http.ResponseWriter, name string, data any) error
RenderWithStatusFn func(w http.ResponseWriter, status int, name string, data any) error
RegisterFuncsFn func(funcs template.FuncMap)
Calls []Call
// contains filtered or unexported fields
}
MockUI is a configurable mock of gas.UIProvider. Each method delegates to its corresponding Fn field if set, otherwise returns the zero value without writing to the ResponseWriter. All calls are recorded in the Calls slice for assertions.
func (*MockUI) RegisterFuncs ¶
RegisterFuncs records the call and delegates to RegisterFuncsFn if set.
func (*MockUI) RenderFragment ¶
RenderFragment records the call and delegates to RenderFragmentFn if set.
func (*MockUI) RenderWithStatus ¶
RenderWithStatus records the call and delegates to RenderWithStatusFn if set.