Documentation
¶
Overview ¶
Package sessiontest holds the shared Session test support: a controlled memory storage and an opened Session kernel with its publications.
Ports packages/durable/test/session-support.ts
Index ¶
- func CreateConversation(t testing.TB, kernel *session.SessionImpl) durable.ConversationId
- func DocumentChanges(publication durable.CommitPublication) []durable.DocumentChange
- func DocumentCopyChanges(publication durable.CommitPublication) []durable.DocumentCopyChange
- func Flush(kernel *session.SessionImpl)
- type ControlledStorage
- func (controlled *ControlledStorage) AdmittedCommits() [][]durable.StorageWrite
- func (controlled *ControlledStorage) Commit(ctx context.Context, writes []durable.StorageWrite) (durable.Seq, error)
- func (controlled *ControlledStorage) Commits() [][]durable.StorageWrite
- func (controlled *ControlledStorage) Crash()
- func (controlled *ControlledStorage) Document(ctx context.Context, id durable.DocumentId, at durable.DocumentPoint) (*durable.StoredDocument, error)
- func (controlled *ControlledStorage) DocumentReadCount() int
- func (controlled *ControlledStorage) FailNextCommit(err error)
- func (controlled *ControlledStorage) FindDocument(ctx context.Context, address durable.DocumentAddress, at durable.DocumentPoint) (*durable.DocumentRecord, error)
- func (controlled *ControlledStorage) HoldCommits() *Gate
- func (controlled *ControlledStorage) HoldFindDocument() *Gate
- func (controlled *ControlledStorage) LastCommit() []durable.StorageWrite
- func (controlled *ControlledStorage) MintCount() int
- func (controlled *ControlledStorage) MintId() (int64, error)
- type Gate
- type Harness
- type Publications
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CreateConversation ¶
func CreateConversation(t testing.TB, kernel *session.SessionImpl) durable.ConversationId
CreateConversation creates one ownerless conversation and returns its ID.
func DocumentChanges ¶
func DocumentChanges(publication durable.CommitPublication) []durable.DocumentChange
DocumentChanges returns the document changes of a publication.
func DocumentCopyChanges ¶
func DocumentCopyChanges(publication durable.CommitPublication) []durable.DocumentCopyChange
DocumentCopyChanges returns the document copy changes of a publication.
func Flush ¶
func Flush(kernel *session.SessionImpl)
Flush waits until every scheduled watch and state delivery drained, as upstream's flush waits one macrotask.
Types ¶
type ControlledStorage ¶
type ControlledStorage struct {
*storage.MemoryStorage
// contains filtered or unexported fields
}
ControlledStorage is memory storage with observable commits, held calls, and injected commit failures.
func NewControlledStorage ¶
func NewControlledStorage() *ControlledStorage
NewControlledStorage returns an empty controlled memory storage.
func (*ControlledStorage) AdmittedCommits ¶
func (controlled *ControlledStorage) AdmittedCommits() [][]durable.StorageWrite
AdmittedCommits returns the exact batches the Session admitted.
func (*ControlledStorage) Commit ¶
func (controlled *ControlledStorage) Commit(ctx context.Context, writes []durable.StorageWrite) (durable.Seq, error)
Commit records the batch, honors a held gate and an injected failure, then commits.
func (*ControlledStorage) Commits ¶
func (controlled *ControlledStorage) Commits() [][]durable.StorageWrite
Commits returns detached copies of the admitted batches for value assertions.
func (*ControlledStorage) Crash ¶
func (controlled *ControlledStorage) Crash()
Crash simulates a crash during the held commit: it never reaches storage, and later commits proceed.
func (*ControlledStorage) Document ¶
func (controlled *ControlledStorage) Document(ctx context.Context, id durable.DocumentId, at durable.DocumentPoint) (*durable.StoredDocument, error)
Document counts and materializes.
func (*ControlledStorage) DocumentReadCount ¶
func (controlled *ControlledStorage) DocumentReadCount() int
DocumentReadCount returns the number of document materializations.
func (*ControlledStorage) FailNextCommit ¶
func (controlled *ControlledStorage) FailNextCommit(err error)
FailNextCommit makes the next commit fail with err.
func (*ControlledStorage) FindDocument ¶
func (controlled *ControlledStorage) FindDocument(ctx context.Context, address durable.DocumentAddress, at durable.DocumentPoint) (*durable.DocumentRecord, error)
FindDocument honors a held gate, then resolves.
func (*ControlledStorage) HoldCommits ¶
func (controlled *ControlledStorage) HoldCommits() *Gate
HoldCommits holds every commit until the returned gate is released.
func (*ControlledStorage) HoldFindDocument ¶
func (controlled *ControlledStorage) HoldFindDocument() *Gate
HoldFindDocument holds every document lookup until the returned gate is released.
func (*ControlledStorage) LastCommit ¶
func (controlled *ControlledStorage) LastCommit() []durable.StorageWrite
LastCommit returns the newest admitted batch.
func (*ControlledStorage) MintCount ¶
func (controlled *ControlledStorage) MintCount() int
MintCount returns the number of minted IDs.
func (*ControlledStorage) MintId ¶
func (controlled *ControlledStorage) MintId() (int64, error)
MintId counts and mints.
type Gate ¶
type Gate struct {
// contains filtered or unexported fields
}
Gate holds calls until released and reports when the first held call arrives.
type Harness ¶
type Harness struct {
Storage *ControlledStorage
Session *session.SessionImpl
Publications *Publications
}
Harness is a Session kernel plus its controlled storage and every committed publication.
func OpenReportingTestSession ¶
OpenReportingTestSession is OpenTestSession with a Session that hands its failure, and the errors of its listeners, to report.
func OpenTestSession ¶
func OpenTestSession() Harness
OpenTestSession opens a Session kernel over a controlled storage.
type Publications ¶
type Publications struct {
// contains filtered or unexported fields
}
Publications collects every committed publication.
func (*Publications) All ¶
func (publications *Publications) All() []durable.CommitPublication
All returns the publications so far.
func (*Publications) Last ¶
func (publications *Publications) Last() durable.CommitPublication
Last returns the newest publication.
func (*Publications) Len ¶
func (publications *Publications) Len() int
Len returns the number of publications.