Documentation
¶
Overview ¶
Package storetest is the test every CronWatch store passes: the memory store, and the sqlstore package on SQLite, Postgres, and MySQL. It is the SDK's store-conformance.ts, and a replay of the store cases in the repository's conformance/store.json. Run it against a store of your own:
func TestMyStore(t *testing.T) {
storetest.Run(t, func(t *testing.T) cronwatch.Store { return mystore.New(...) })
}
Run is the one name here the 1.x releases promise. The other exported names are the module's own test kit (its fixture replays, clocks, and captures), deprecated, and go in 1.0.
Index ¶
- Constants
- func FinishOnce(t *testing.T, shared func(t *testing.T) Shared)deprecated
- func NewRun(id, job string, status cronwatch.RunStatus, startedAt int64) cronwatch.Rundeprecated
- func NewRunPlain(id, job string, status cronwatch.RunStatus, startedAt int64) cronwatch.Rundeprecated
- func ReplayFixture(t *testing.T, path string, newStore func(t *testing.T) cronwatch.Store)deprecated
- func ReplayForeignVersions(t *testing.T, path string, store cronwatch.Store, ...)deprecated
- func Run(t *testing.T, newStore func(t *testing.T) cronwatch.Store)
- type Capturedeprecated
- type Clockdeprecated
- func NewClock(start int64) *Clockdeprecated
- type Errorsdeprecated
- type Processdeprecated
- type Shareddeprecated
Constants ¶
const T0 int64 = 1767605400000
T0 is Monday 2026-01-05 09:30:00Z, the SDK tests' clock start.
Deprecated: only Run is promised; this is the module's own test kit, and goes in 1.0.
Variables ¶
This section is empty.
Functions ¶
func FinishOnce
deprecated
FinishOnce is finish-once.test.ts's tests over several stores sharing one database: however many processes finish a run, it is recorded and judged once. shared makes a fresh database each time it is called.
Deprecated: only Run is promised; this is the module's own test kit, and goes in 1.0.
func NewRun
deprecated
NewRun is a run as the contract test writes them: finished ten milliseconds after it started unless it is running, with one metric.
Deprecated: only Run is promised; this is the module's own test kit, and goes in 1.0.
func ReplayFixture
deprecated
ReplayFixture replays the store cases of conformance/store.json (at path) against stores from newStore, which must each be empty: prune scripts, CompareAndSetState steps, and UpdateRunIf steps, each read back and compared with what the SDK's memory store answered.
Deprecated: only Run is promised; this is the module's own test kit, and goes in 1.0.
func ReplayForeignVersions
deprecated
added in
v0.8.0
func ReplayForeignVersions(t *testing.T, path string, store cronwatch.Store, writeRaw func(text string) error)
ReplayForeignVersions replays the foreignVersion cases of conformance/store.json (at path) against store, which must implement cronwatch.StateComparer: a state row another process wrote, its version in any shape (1.5, "x", -1, 2.0, 2^53), counts as the SDK's stateVersion() reads it, a whole number from 0 to 2^53 - 1 or else 0. So a write expecting any other version is refused, and one expecting it goes through, where a brittle cast would fail every write of the job for good. writeRaw stores a state row for job "v" holding the JSON text given as it is, as a store's own writes never would; the replay deletes job "v" before each case.
Deprecated: only Run is promised; this is the module's own test kit, and goes in 1.0.
Types ¶
type Capture
deprecated
Capture is a channel that keeps the alerts it is sent. Read them with List (or Types), which take its lock: a client sends from goroutines of its own, so reading Alerts directly is safe only once every send has returned.
Deprecated: only Run is promised; this is the module's own test kit, and goes in 1.0.
type Errors
deprecated
type Errors struct {
// contains filtered or unexported fields
}
Errors keeps what a client reports, as "where: message".
Deprecated: only Run is promised; this is the module's own test kit, and goes in 1.0.
type Process
deprecated
Process is one client over a shared store, as one process would have.
Deprecated: only Run is promised; this is the module's own test kit, and goes in 1.0.
type Shared
deprecated
type Shared struct {
Done func()
}
Shared opens stores over one database, as several processes would have them: each call to Open is another store on the same data.
Deprecated: only Run is promised; this is the module's own test kit, and goes in 1.0.