dbtest

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Jan 18, 2022 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RandomID

func RandomID() note.ID

RandomID returns a pseudo-random ID using package math/rand.

func TestLoader

func TestLoader(t testing.TB, l note.Loader)

TestLoader will run a few tests against l that are meant to fail if l does not implement the note.Loader interface correctly.

Types

type BreakingLoader

type BreakingLoader struct {
	note.Loader
	Count      int
	ErrAtCount int
	Err        error
}

BreakingLoader is an optionally partly broken proxy to a Loader.

func (*BreakingLoader) Load

func (l *BreakingLoader) Load(ids []note.ID) ([]note.GraphNote, error)

Load returns l.Err when l.Count==l.ErrAtCount, and otherwise return l.Loader.Load(ids).

In any case, Load() will increment Count.

When l.Err is nil, l is just a Count incrementing proxy to l.Loader.

type BrokenNote

type BrokenNote struct {
	note.ID
	Err error
}

BrokenNote implements note.GraphNote but always returns an error when attempting to read anything other than the ID.

func (BrokenNote) GetContents

func (n BrokenNote) GetContents() ([]note.GraphNote, error)

GetContents always returns n.Err.

func (BrokenNote) GetID

func (n BrokenNote) GetID() note.ID

GetID always gets the ID.

func (BrokenNote) GetTypes

func (n BrokenNote) GetTypes() ([]note.GraphNote, error)

GetTypes always returns n.Err.

func (BrokenNote) GetValue

func (n BrokenNote) GetValue() (string, note.GraphNote, error)

GetValue always returns n.Err.

type BrokenNoteLoader

type BrokenNoteLoader struct{ Err error }

BrokenNoteLoader loads instances of BrokenNote.

func (*BrokenNoteLoader) Load

func (l *BrokenNoteLoader) Load(ids []note.ID) ([]note.GraphNote, error)

Load will always successfully load all requested notes without error, but the returned notes will always return errors when attempts are made to read them.

Jump to

Keyboard shortcuts

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