Documentation
¶
Overview ¶
Package journal records Management API calls in a bounded in-memory ring so tests can assert on what the application under test actually sent.
Index ¶
Constants ¶
const MaxStoredBody = 64 << 10
MaxStoredBody is the most request-body bytes kept per entry.
Variables ¶
This section is empty.
Functions ¶
func MarkMatched ¶
MarkMatched records that a stub served the call. ExpectationID is empty for the SSE stream. It is a no-op when ctx has no journal slot.
Types ¶
type Entry ¶
type Entry struct {
ID string `json:"id"`
ReceivedAt time.Time `json:"receivedAt"`
Method string `json:"method"`
Path string `json:"path"`
Operation string `json:"operation"`
Query url.Values `json:"query"`
Headers http.Header `json:"headers"`
Body json.RawMessage `json:"body,omitempty"`
BodyTruncated bool `json:"bodyTruncated,omitempty"`
Status int `json:"status"`
Outcome Outcome `json:"outcome"`
ExpectationID string `json:"expectationId,omitempty"`
NearMisses []matches.NearMiss `json:"nearMisses,omitempty"`
}
Entry is one recorded Management API call.
type Filter ¶
type Filter struct{ Method, Path string }
Filter narrows List and Unmatched. Empty fields match everything. A Path containing "{...}" is compared with the entry's Operation, otherwise with its concrete Path.
type Journal ¶
type Journal struct {
// contains filtered or unexported fields
}
Journal is a fixed-size ring of entries, safe for concurrent use.
func (*Journal) Middleware ¶
Middleware records every /api/v2/ call once its response starts.
type Outcome ¶
type Outcome string
Outcome says how the mock resolved a recorded call.
const ( // OutcomeMatched means a stub (or the SSE stream) served the call. OutcomeMatched Outcome = "matched" // OutcomeNoMatch means the call was well formed but no stub matched. OutcomeNoMatch Outcome = "no_match" // OutcomeRejected means the call never reached stub matching (auth, // validation, unknown route, ...). OutcomeRejected Outcome = "rejected" )