dbtest

package
v0.0.4 Latest Latest
Warning

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

Go to latest
Published: Jul 25, 2020 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() notes.ID

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

func TestLoader

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

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

Types

type BreakingLoader

type BreakingLoader struct {
	notes.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 []notes.ID) ([]notes.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 {
	notes.ID
	Err error
}

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

func (BrokenNote) GetContents

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

GetContents always returns n.Err.

func (BrokenNote) GetID

func (n BrokenNote) GetID() notes.ID

GetID always gets the ID.

func (BrokenNote) GetValue

func (n BrokenNote) GetValue() (string, notes.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 []notes.ID) ([]notes.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