Help us shape the future of Go! Take the 2026 Go Developer Survey

redistest

package
v1.10.0 Latest Latest
Warning

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

Go to latest
Published: Nov 3, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package redistest keeps each test that runs against a live redis inside a key prefix of its own.

`go test ./...` runs packages in parallel, and two checkouts can run against the same redis at once. A redis store sees every key under its prefix: Migrate walks them all and the indexes are one set per prefix. So each test store gets a fresh prefix through store/redis.WithKeyPrefix, and deletes only that prefix when it ends.

Index

Constants

View Source
const Root = "chronicle:"

Root is the prefix every key a test writes starts with. It matches store/redis.DefaultKeyPrefix, which this package can't import: the redis package's own tests import this one.

Variables

This section is empty.

Functions

func Isolate

func Isolate(ctx context.Context, t testing.TB, rdb goredis.UniversalClient, dsn string) string

Isolate returns a key prefix under Root that no other test uses, and deletes every key under it when t ends. Pass the result to store/redis.WithKeyPrefix.

Before handing it back, it refuses (t.Fatalf) a database holding any key outside Root. On the machine these tests were written on, the DSN a developer reaches for first (localhost:6379) is another project's live redis. The guard and the prefix-scoped delete are independent, so neither one failing can empty it. dsn is only used to name the database in that message, without its password.

Types

This section is empty.

Jump to

Keyboard shortcuts

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