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

authstoretest

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Oct 27, 2026 License: MIT Imports: 15 Imported by: 0

Documentation

Overview

Package authstoretest checks baseAgent.AuthStore implementations against the contract documented on baseAgent.AuthStore.

Call Run from a test in the store's package, with two stores over the same database:

func TestConformance(t *testing.T) {
	authstoretest.Run(t, func(t *testing.T) baseAgent.AuthStore {
		return newTestStore(t)
	})
}

Run it with go test -timeout: a broken lock usually deadlocks rather than failing.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Run

func Run(t *testing.T, newStore func(t *testing.T) baseAgent.AuthStore)

Run checks the store returned by newStore against the AuthStore contract. newStore is called twice per subtest, and the subtest uses both stores, often at once. They must share one database, as two processes would, so a lock held only in memory fails. Every subtest uses fresh owner IDs, so the stores may share a database with other tests.

Types

type MemoryStore

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

MemoryStore is an in-memory baseAgent.AuthStore. It is a reference implementation of the contract and a store for tests and single-process apps. Values are not encrypted, and it keeps a small lock for every key it has seen.

func NewMemoryStore

func NewMemoryStore() *MemoryStore

NewMemoryStore returns an empty MemoryStore.

func (*MemoryStore) Delete

func (s *MemoryStore) Delete(ctx context.Context, ownerID, namespace, name string) error

func (*MemoryStore) Get

func (s *MemoryStore) Get(ctx context.Context, ownerID, namespace, name string) ([]byte, error)

func (*MemoryStore) List

func (s *MemoryStore) List(ctx context.Context, ownerID, namespace string) ([]string, error)

func (*MemoryStore) Modify

func (s *MemoryStore) Modify(ctx context.Context, ownerID, namespace, name string, fn func(current []byte) ([]byte, error)) ([]byte, error)

Jump to

Keyboard shortcuts

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