Documentation
¶
Overview ¶
Package testutil provides helpers for recording Slack API calls during tests.
The central type is Recorder, which captures every Slack API invocation made through a SlackClientMock built via NewSlackClientMock. Calls are stored in chronological order across all methods so that tests (in particular the Phase 0 regression protection golden tests under chat-session-redesign spec) can assert against a stable JSON serialization of the entire interaction.
Usage:
rec := testutil.NewRecorder() client := testutil.NewSlackClientMock(rec) // ... use client in production code paths ... got := rec.CallsJSON() golden.Assert(t, "fixture_name.json", got)
Determinism: timestamps returned from PostMessageContext are synthesized by the recorder as "1700000000.{seq:06d}" so no wall-clock randomness leaks into the captured stream. MsgOption values are decoded via slack.UnsafeApplyMsgOptions, which yields the same URL-encoded payload Slack itself would see on the wire.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewSlackClientMock ¶
func NewSlackClientMock(r *Recorder) *mock.SlackClientMock
NewSlackClientMock constructs a SlackClientMock whose every method records invocations into the provided Recorder before returning safe default values.
Tests may override any Func field on the returned mock to customize a specific method's behavior (for example, to simulate a failure or to return a particular conversation history payload). When a Func is overridden the override is fully responsible for recording the call if that is desired.
Types ¶
type Call ¶
type Call struct {
Seq int `json:"seq"`
Method string `json:"method"`
Args json.RawMessage `json:"args"`
}
Call captures a single Slack API invocation in a form suitable for deterministic JSON comparison.
type Recorder ¶
type Recorder struct {
// contains filtered or unexported fields
}
Recorder stores Slack API calls in the order they were observed.
A Recorder is safe for concurrent use.