dotest

package
v0.5.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 9, 2026 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Overview

Package dotest runs durable object sessions in memory, for tests: a host's tests of its agent on the durable object runtime, and the runtime's own. Platform stops objects, fires their alarms and fails their reads and writes the way a real platform can, so a test sees what a session does when that happens.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Platform

type Platform struct {
	// contains filtered or unexported fields
}

Platform is a durableobject.Platform in memory. Each object's storage outlives the object: after Evict, the next request makes a new object over the same storage, as a platform does.

func New

func New(cfg durableobject.Config) *Platform

New returns an empty Platform whose objects run with cfg.

func NewWire

func NewWire(cfg durableobject.Config) *Platform

NewWire is New, but every call to an object, from a client or from another object, goes over the object protocol (durableobject.Handler and durableobject.Remote), as it does on a platform where objects are remote. Evict also breaks the object's open streams, as a platform that takes an object away does.

func (*Platform) Alarm

func (p *Platform) Alarm(id session.ID) time.Time

Alarm is the alarm id's object set; zero when none is set.

func (*Platform) Evict

func (p *Platform) Evict(id session.ID)

Evict stops id's object, as a platform that takes it away does: what it still runs can no longer read or write its storage. The next request makes a new object over the same storage.

func (*Platform) FailReads

func (p *Platform) FailReads(id session.ID, fail func(key string) bool)

FailReads makes id's storage fail each read whose key fail reports, as an outage does: a Get's key, or a Scan's prefix. Nil makes every read work again.

func (*Platform) FailWrites

func (p *Platform) FailWrites(id session.ID, fail func(ops []durableobject.Op) bool)

FailWrites makes id's storage fail each write whose ops fail reports, as an outage does; nil makes every write work again.

func (*Platform) FireAlarm

func (p *Platform) FireAlarm(ctx context.Context, id session.ID) error

FireAlarm delivers id's alarm, as the platform does when it is due.

func (*Platform) Idle

func (p *Platform) Idle(ctx context.Context, id session.ID) error

Idle returns once id's object runs nothing (durableobject.Object.Idle).

func (*Platform) Keys

func (p *Platform) Keys(id session.ID) []string

Keys is every key id's storage holds, in order.

func (*Platform) Object

func (p *Platform) Object(id session.ID) durableobject.Ref

Object implements durableobject.Platform. It is the id's live object, made on first use over the id's storage; on a NewWire platform, a Ref that reaches it over the object protocol.

func (*Platform) WaitAlarm

func (p *Platform) WaitAlarm(ctx context.Context, id session.ID, after time.Time) (time.Time, error)

WaitAlarm returns id's alarm once its object set it to a time after after, or, with ctx's error, once ctx ends.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL