Documentation ¶
Overview ¶
Package test contains utility and helper methods for testing plugins
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( // ErrorHandler is a plugin.Handler and always returns an error ErrorHandler = HandlerFunc(func(_ context.Context, req, res *dhcpv4.DHCPv4) error { return errors.New("simulated error") }) // NoOpHandler is a No-Operation plugin.Handler NoOpHandler = HandlerFunc(func(_ context.Context, req, res *dhcpv4.DHCPv4) error { return nil }) )
Functions ¶
func CreateTestBed ¶
func CreateTestBed(t *testing.T, input string) *caddy.Controller
CreateTestBed creates a new caddy.Controller that is configured for testing the setup and configuration of plugins. It creates a dummy server block in the context of "dhcpv4" server type so plugins can safely assume dhcpserver.GetConfig(ctrl) will return a valid configuration. The server block itself is configured to serve on 127.0.0.1/8
Types ¶
type HandlerFunc ¶
HandlerFunc implements plugin.Handler
type ReplaceFunc ¶
ReplaceFunc is called when Replacer.Replace is called
type Replacer ¶
type Replacer struct { Getter GetFunc Setter SetFunc Replacer ReplaceFunc }
Replacer implements the replacer.Replacer interface
func WithReplacer ¶
WithReplacer returns a context that has a test replacer assigned
Click to show internal directories.
Click to hide internal directories.