testutil

package
v2.11.2 Latest Latest
Warning

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

Go to latest
Published: Jul 31, 2026 License: GPL-3.0 Imports: 14 Imported by: 0

Documentation

Overview

Package testutil provides test helpers for the persistence layer.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BlockPathWithDirectory

func BlockPathWithDirectory(t *testing.T, path string)

BlockPathWithDirectory ensures path is occupied by a directory.

func BlockPathWithFile

func BlockPathWithFile(t *testing.T, path string)

BlockPathWithFile ensures path is occupied by a regular file.

func SkipIfPOSIXPermissionErrorsUnsupported

func SkipIfPOSIXPermissionErrorsUnsupported(t *testing.T)

SkipIfPOSIXPermissionErrorsUnsupported skips tests that rely on chmod-based permission failures, which are not reliable on Windows or as root.

func SupportsPOSIXPermissionBits

func SupportsPOSIXPermissionBits() bool

SupportsPOSIXPermissionBits reports whether exact Unix permission-bit assertions are meaningful on the current platform.

Types

type MemoryBackend

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

MemoryBackend is an in-memory persis.Backend for use in unit tests. It is not persistent and not safe to share across processes.

func NewMemoryBackend

func NewMemoryBackend() *MemoryBackend

NewMemoryBackend returns an empty in-memory backend.

func (*MemoryBackend) Close

func (b *MemoryBackend) Close() error

func (*MemoryBackend) Collection

func (b *MemoryBackend) Collection(name string) persis.Collection

type MemoryCollection

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

MemoryCollection is a single in-memory persis.Collection.

func (*MemoryCollection) CompareAndDelete

func (c *MemoryCollection) CompareAndDelete(_ context.Context, expected *persis.Record) error

func (*MemoryCollection) CompareAndSwap

func (c *MemoryCollection) CompareAndSwap(_ context.Context, id string, expected, next []byte) error

func (*MemoryCollection) Create

func (c *MemoryCollection) Create(_ context.Context, rec *persis.Record) error

Create atomically inserts rec. Returns persis.ErrConflict when a record with rec.ID already exists.

func (*MemoryCollection) Delete

func (c *MemoryCollection) Delete(ctx context.Context, id string) error

func (*MemoryCollection) DeleteIfExists

func (c *MemoryCollection) DeleteIfExists(_ context.Context, id string) (bool, error)

DeleteIfExists removes a record and reports whether it existed.

func (*MemoryCollection) Get

func (*MemoryCollection) List

func (*MemoryCollection) Put

func (*MemoryCollection) RecordIDs

func (c *MemoryCollection) RecordIDs(_ context.Context, prefix string) ([]string, error)

RecordIDs returns record IDs matching prefix without decoding record payloads.

func (*MemoryCollection) RecordVersion

func (c *MemoryCollection) RecordVersion(_ context.Context, id string) (string, error)

RecordVersion returns a cheap version token for cache validation.

func (*MemoryCollection) WithLock

func (c *MemoryCollection) WithLock(ctx context.Context, key string, fn func() error) error

Jump to

Keyboard shortcuts

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