Documentation
¶
Index ¶
- Variables
- func RunService(t *testing.T, h Harness)
- type Fake
- func (f *Fake) ListFor(_ context.Context, _ db.Tx[db.Tenant], recipient uuid.UUID, q crud.Query) ([]*contracts.Notification, int64, error)
- func (f *Fake) MarkRead(_ context.Context, _ db.Tx[db.Tenant], id, recipient uuid.UUID) (*contracts.Notification, error)
- func (f *Fake) Notify(ctx context.Context, _ db.Tx[db.Tenant], n contracts.Notice) (*contracts.Notification, error)
- func (f *Fake) Published() []string
- type Fixture
- type Harness
Constants ¶
This section is empty.
Variables ¶
var ( Ada = uuid.New() Bob = uuid.New() AdaEmail = "ada@acme.example.com" )
Ada is the recipient the suite writes to, and Bob is somebody else. They are exported because a harness has to tell the RecipientLookup which of them has an address: Ada does, Bob does not, which is what makes "a recipient with no address gets the row and no mail" a case.
Functions ¶
func RunService ¶
RunService is the conformance suite. Every implementation of contracts.Service passes it, or it is not one.
Types ¶
type Fake ¶
type Fake struct {
// contains filtered or unexported fields
}
Fake is contracts.Service over a slice: the same rules, no database, no transaction. A consumer that wants to test what it does when somebody is notified takes one of these instead of a Postgres.
It ignores the transaction it is handed, which is the honest limit of it: nothing here commits, so it cannot tell a caller that a write did not.
func NewFake ¶
func NewFake() *Fake
NewFake returns an empty store in which Ada has an address and Bob does not, which is what the conformance suite's two cases are about.
func (*Fake) ListFor ¶
func (f *Fake) ListFor(_ context.Context, _ db.Tx[db.Tenant], recipient uuid.UUID, q crud.Query) ([]*contracts.Notification, int64, error)
ListFor mirrors internal.Service.ListFor: this recipient's rows, newest first, then paged.
func (*Fake) MarkRead ¶
func (f *Fake) MarkRead(_ context.Context, _ db.Tx[db.Tenant], id, recipient uuid.UUID) (*contracts.Notification, error)
MarkRead mirrors internal.Service.MarkRead.
type Fixture ¶
type Fixture struct {
Ctx context.Context
Tx db.Tx[db.Tenant]
Service contracts.Service
// Published is the names of the events published so far, in order. It is
// what holds MarkRead to saying nothing the second time, which is the half
// of the promise a return value cannot show.
Published func() []string
}
Fixture is one case's world: a Service, the transaction its commands take, and a way to see what was published.