Documentation
¶
Overview ¶
Package conformance is the shared semantic test-suite for docstore.Store implementations. Every backend runs it from its own tests:
func TestConformance(t *testing.T) {
conformance.Run(t, func(t *testing.T) docstore.Store { return memory.New() })
}
The suite pins down SPEC §5.2 (filters, ordering, missing vs null, type strictness, pagination) plus the Store contract (CRUD, versions, timestamps, collections, counts, site isolation, atomic updates, value canonicalisation and the docstore.WithLimits wrapper), so that all backends behave identically.
The data-only query cases also live in querycases.json (QueryCasesJSON), a language-neutral fixture of wire-format queries and expected results that the Cloudflare edition and the black-box conformance/ suite can run too, so every Backyard edition is held to the same semantics.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var QueryCasesJSON []byte
QueryCasesJSON is the shared, language-neutral query-semantics suite (querycases.json in this directory). It pins SPEC §5.2 with wire-format queries and expected results so that every implementation of the Backyard database — the Go backends here, the Cloudflare edition's SiteDO and the black-box conformance/ suite — can run the very same cases.
Format: "collections" maps a collection name to its documents ({"id", "data"}), which must be created in the listed order; each entry of "cases" names a collection, a Query in the JSON shape of POST /__backyard/api/db/{c}/query, the expected document ids in order ("want") and the expected "has_more".
Functions ¶
func Run ¶
Run executes the suite. newStore is called once per subtest (subtests run in parallel) and must return a ready store; it may return the same shared store every time, because each subtest works in its own randomly named sites. Run never closes stores: newStore should register cleanup with t.Cleanup when needed.
Types ¶
type QueryCase ¶
type QueryCase struct {
Name string `json:"name"`
Collection string `json:"collection"`
Query docstore.Query `json:"query"`
Want []string `json:"want"`
HasMore bool `json:"has_more"`
}
QueryCase is one query with its expected result.
type QueryCases ¶
type QueryCases struct {
Version int `json:"version"`
Collections map[string][]CaseDoc `json:"collections"`
Cases []QueryCase `json:"cases"`
}
QueryCases is the decoded form of QueryCasesJSON.
func LoadQueryCases ¶
func LoadQueryCases() (*QueryCases, error)
LoadQueryCases decodes QueryCasesJSON.