Documentation
¶
Overview ¶
Package test provides a conformance harness for chat-platform providers.
The compiler checks a provider's method set. It cannot check the rules a caller actually relies on: that asking for a read-only provider yields one with nothing to post through, that Close is safe on a provider that never connected, that Messages returns a channel a caller can range over, or that the capabilities a provider claims are the ones it has. A provider can satisfy every interface in the contract and still be wrong in each of those ways.
Run it from the provider's own test suite:
func TestConformance(t *testing.T) {
chatplatformtest.RunProviderConformance(t, chatplatformtest.ConformanceConfig{
NewProvider: func(c chatplatform.Config) (*chatplatform.Provider, error) { return mydiscord.New(c) },
Capabilities: chatplatformtest.Capabilities{Moderator: true, Interactive: true},
Space: "123",
AllowedChannel: "456",
})
}
Every check runs without a network. Behaviour that needs a live platform — that a thread is really created, that the allowlist really filters an inbound feed — belongs in the provider's own integration tests, gated behind an environment variable. The harness covers the contract a consumer depends on before a single message arrives.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func RunProviderConformance ¶
func RunProviderConformance(t *testing.T, cfg ConformanceConfig)
RunProviderConformance runs every check and reports what it finds.
Types ¶
type Capabilities ¶
Capabilities declares what the provider under test supports, so the harness can tell "correctly does not offer this" apart from "should and does not".
Declare honestly. Claiming a capability the provider lacks makes the harness look for something impossible; omitting one it has means nobody discovers it.
type ConformanceConfig ¶
type ConformanceConfig struct {
// NewProvider builds a provider from the given config. Called once per
// check, so each gets an independent instance.
NewProvider func(chatplatform.Config) (*chatplatform.Provider, error)
// Capabilities the provider claims.
Capabilities Capabilities
// Space is the guild, workspace or network the provider serves.
Space chatplatform.ID
// AllowedChannel is a channel the provider should accept in its allowlist.
AllowedChannel chatplatform.ID
}
ConformanceConfig configures a run.