Documentation
¶
Overview ¶
Package testutil provides test helpers for the persistence layer.
Index ¶
- func BlockPathWithDirectory(t *testing.T, path string)
- func BlockPathWithFile(t *testing.T, path string)
- func SkipIfPOSIXPermissionErrorsUnsupported(t *testing.T)
- func SupportsPOSIXPermissionBits() bool
- type MemoryBackend
- type MemoryCollection
- func (c *MemoryCollection) CompareAndDelete(_ context.Context, expected *persis.Record) error
- func (c *MemoryCollection) CompareAndSwap(_ context.Context, id string, expected, next []byte) error
- func (c *MemoryCollection) Create(_ context.Context, rec *persis.Record) error
- func (c *MemoryCollection) Delete(ctx context.Context, id string) error
- func (c *MemoryCollection) DeleteIfExists(_ context.Context, id string) (bool, error)
- func (c *MemoryCollection) Get(_ context.Context, id string) (*persis.Record, error)
- func (c *MemoryCollection) List(_ context.Context, q persis.ListQuery) (*persis.Page, error)
- func (c *MemoryCollection) Put(_ context.Context, rec *persis.Record) error
- func (c *MemoryCollection) RecordIDs(_ context.Context, prefix string) ([]string, error)
- func (c *MemoryCollection) RecordVersion(_ context.Context, id string) (string, error)
- func (c *MemoryCollection) WithLock(ctx context.Context, key string, fn func() error) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BlockPathWithDirectory ¶
BlockPathWithDirectory ensures path is occupied by a directory.
func BlockPathWithFile ¶
BlockPathWithFile ensures path is occupied by a regular file.
func SkipIfPOSIXPermissionErrorsUnsupported ¶
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 (*MemoryCollection) CompareAndSwap ¶
func (*MemoryCollection) Create ¶
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 ¶
DeleteIfExists removes a record and reports whether it existed.
func (*MemoryCollection) RecordIDs ¶
RecordIDs returns record IDs matching prefix without decoding record payloads.
func (*MemoryCollection) RecordVersion ¶
RecordVersion returns a cheap version token for cache validation.