userstatetest

package
v0.0.0-...-8acabe7 Latest Latest
Warning

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

Go to latest
Published: Aug 21, 2026 License: AGPL-3.0 Imports: 5 Imported by: 0

Documentation

Overview

Package userstatetest is the conformance harness every userstate.Store implementation must pass.

It exists for the same reason internal/store/storetest does: three backends without a shared contract test are three subtly different behaviors, and the one that diverges is the one nobody runs locally. The expiry and replace-don't-stack rules in particular are easy to implement plausibly-but-differently in Go maps, on disk, and in SQL.

Every assertion here is deterministic — no wall clock, no sleeps — because userstate.Store takes `now` as a parameter. A suite that slept would be slow and flaky and would still not pin the boundary conditions.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RunAll

func RunAll(t *testing.T, f Factory)

RunAll runs every conformance suite against f.

func RunClosedTests

func RunClosedTests(t *testing.T, f Factory)

RunClosedTests pins that a closed store fails loudly rather than silently accepting writes that go nowhere.

func RunIsolationTests

func RunIsolationTests(t *testing.T, f Factory)

RunIsolationTests pins that state is scoped per user. A leak here shows a user someone else's snoozes — mild in itself, but it would also mean the keying is wrong in a way that corrupts cooldown for everyone.

func RunMuteTests

func RunMuteTests(t *testing.T, f Factory)

RunMuteTests pins per-source muting and its reversibility.

func RunPruneTests

func RunPruneTests(t *testing.T, f Factory)

RunPruneTests pins housekeeping. Pruning must never change an answer — only reclaim space — so correctness cannot depend on it having run.

func RunShownTests

func RunShownTests(t *testing.T, f Factory)

RunShownTests pins the last-shown record backing cooldown.

func RunSnoozeTests

func RunSnoozeTests(t *testing.T, f Factory)

RunSnoozeTests pins snooze semantics, including the boundary condition and the replace-don't-stack rule.

Types

type Factory

type Factory func(t *testing.T) userstate.Store

Factory returns a fresh, empty store for one subtest. Cleanup (including Close) is the factory's responsibility, normally via t.Cleanup.

Jump to

Keyboard shortcuts

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