Documentation
¶
Overview ¶
Package test helps a consumer look for a handler panic before one happens.
It proves nothing, and that is not modesty ¶
A corpus and a fuzz target are testing, not verification. Passing means no panic was found on those inputs, never that the handler is panic-free. A helper that let somebody believe otherwise would be worse than no helper, because the module's panic counter would then read as impossible rather than as unexpected.
The module recovers a handler panic at the goroutine it owns, and the subscription is restarted under its own policy. That is a backstop, and a backstop is not a strategy. This package is the strategy.
Who it is for ¶
A consumer, running Handler against the corpus in an ordinary unit test, and adding a fuzz target seeded from Corpus so the toolchain finds the rest.
A backend implementer wants gitlab.com/phpboyscout/go/messaging/conformance instead.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Fuzz ¶
Fuzz runs h against one arbitrary payload, for use inside a Go fuzz target seeded from Corpus.
func FuzzHandler(f *testing.F) {
for _, c := range test.Corpus() {
f.Add(c.Delivery.Event.Data)
}
f.Fuzz(func(t *testing.T, data []byte) {
test.Fuzz(t, myHandler, data)
})
}
Types ¶
type Case ¶
type Case struct {
// Name says what is adversarial about it. "A handler panicked" without
// saying on which input is not actionable.
Name string
// Delivery is what the handler receives.
Delivery messaging.Delivery
}
Case is one adversarial input, named so a failure says which one.
func Corpus ¶
func Corpus() []Case
Corpus is the adversarial input set.
These are the panics that actually happen in a message handler, which is why they are enumerated once here rather than rediscovered in every consumer. Each is a shape a real broker can deliver: nothing here is impossible, only unwelcome.