Documentation
¶
Overview ¶
Package storetest is the one conformance suite of store.Store. Every adapter (mongostore, sqlitestore) runs it from its own tests:
func TestConformance(t *testing.T) {
storetest.Run(t, func(t *testing.T, cascades ...store.Cascade) store.Store { ... })
}
The suite pins the semantics of Family Hub's MongoDB store (docs/PLAN.md §4.2), so the adapters are interchangeable:
- times are kept at least to the millisecond and come back in UTC (the suite truncates to the millisecond);
- a write to one entity that does not exist returns core.ErrNotFound, except deleting a session and the bulk operations (DeleteByPerson, RevokeKind, RevokeGrantsByResource, RevokeFamily, Delete*Expired*), which are idempotent;
- inserting an id or another unique key that exists returns core.ErrConflict, except the Put methods, which replace; a second active grant of the same (person, client, resource) is core.ErrConflict too;
- Revoke* methods are idempotent: the first revocation time wins;
- an expiry is reached when ExpiresAt <= now; a session is idle when LastSeenAt < now - idle;
- lists are oldest first (by creation time, then id); the audit is newest first, by its store-assigned id, and a cursor that is not an audit id is an error; a limit <= 0 means 50 and a limit above 1000 means 1000;
- AccountStore.Delete runs Cascade.DeletePerson for every person of the account, then Cascade.DeleteAccount; PersonStore.Delete runs Cascade.DeletePerson. Every Cascade runs inside the delete's transaction, and an error from one rolls the whole delete back;
- a person and an invite keep an access term (AccessUntil) and permission ids; no permissions (nil or empty) read back as nil, and SetAccess replaces both, clearing what it is given nothing for;
- an adapter that implements store.Purger (it has no TTL indexes) deletes with Purge what the TTL indexes of the MongoDB adapter would: see the Purge test for the retention. Adapters without a Purger skip that test;
- Tx: commit, rollback on an error from fn, a Tx inside a Tx joins the outer one, and a write inside an open transaction is invisible to a reader outside it until the commit (a reader outside never waits for it).
Each test opens its own store, and the tests run in parallel.
Index ¶
Constants ¶
const PermissionTV = "plugin:tv"
PermissionTV is a permission id the tests use; the gatekeeper never interprets ids.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Call ¶
Call is one call of a Cascade: Account is set for DeleteAccount, Person for DeletePerson.
type Open ¶
Open returns a new, empty store with cascades registered. It arranges (with t.Cleanup) for the store to be closed and its data removed when the test ends.
type Recorder ¶
type Recorder struct {
// contains filtered or unexported fields
}
Recorder is a store.Cascade that records every call and runs an optional hook with the call's context, so a test can write through the store inside the delete's transaction or make the cascade fail.
func (*Recorder) Calls ¶
Calls returns the distinct calls so far, in the order of their first appearance. A store may run a transaction again after a transient error, so a call may happen more than once.
func (*Recorder) DeleteAccount ¶
DeleteAccount implements store.Cascade.
func (*Recorder) DeletePerson ¶
DeletePerson implements store.Cascade.