Skip to content
Source on GitHub (opens in a new tab)
import "github.com/barevoidco/zelk/core/memory/mem"

Package mem is an in-memory memory.Store, for tests. Notes are kept in their stored form, so revisions and parsing behave as in memory/file.

type Option func(*Store)

Option configures a Store.

func WithClock(now func() time.Time) Option

WithClock sets the clock that stamps notes; the default is time.Now.

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

Store is an in-memory memory.Store. The zero value is ready to use, and a Store is safe for concurrent use.

func New(opts ...Option) *Store

New returns an empty Store.

func (s *Store) Delete(ctx context.Context, scope memory.Scope, name string, expect memory.Revision) error

Delete removes scope’s note name, as memory.Store.Delete says.

func (s *Store) List(ctx context.Context, scope memory.Scope) ([]memory.Note, error)

List returns scope’s notes, ordered by name.

func (s *Store) Put(ctx context.Context, n memory.Note, expect memory.Revision) (memory.Note, error)

Put saves n, as memory.Store.Put says.

func (s *Store) Set(scope memory.Scope, name string, data []byte)

Set stores data as scope’s note name, bypassing every check, as a person editing a file would. It is for tests of how notes edited by hand are read.