testutil

package
v0.0.0-...-133031b Latest Latest
Warning

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

Go to latest
Published: May 30, 2023 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Overview

Package testutil provides utilities for easily making test arbor nodes and content.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MakeCommunityOrSkip

func MakeCommunityOrSkip(t *testing.T) (*forest.Identity, forest.Signer, *forest.Community)

func MakeIdentityFromKeyOrSkip

func MakeIdentityFromKeyOrSkip(t *testing.T, privKey, passphrase string) (*forest.Identity, forest.Signer)

func MakeIdentityOrSkip

func MakeIdentityOrSkip(t *testing.T) (*forest.Identity, forest.Signer)

func MakeReplyOrSkip

func MakeReplyOrSkip(t *testing.T) (*forest.Identity, forest.Signer, *forest.Community, *forest.Reply)

func MockCommunity

func MockCommunity(identity *forest.Builder, name string) *forest.Community

MockCommunity creates a fake community for the purposes of testing.

func MockIdentity

func MockIdentity() (*forest.Identity, forest.Signer)

MockIdentity creates a fake identity with a random name for the purposes of testing.

func MockReply

func MockReply(
	identity *forest.Builder,
	parent forest.Node,
) *forest.Reply

MockReply creates a fake reply with random content for the given identity and community.

func QualifiedContentOrSkip

func QualifiedContentOrSkip(t *testing.T, contentType fields.ContentType, content []byte) *fields.QualifiedContent

func RandomBytes

func RandomBytes(length int) []byte

func RandomIdentity

func RandomIdentity(t *testing.T) *forest.Identity

func RandomNodeSlice

func RandomNodeSlice(length int, t *testing.T) ([]*fields.QualifiedHash, []forest.Node)

func RandomQualifiedHash

func RandomQualifiedHash() *fields.QualifiedHash

func RandomQualifiedHashSlice

func RandomQualifiedHashSlice(count int) []*fields.QualifiedHash

func RandomString

func RandomString(length int) string

func SetupStore

func SetupStore(
	t *testing.T,
	prefix, name string,
	init Initializer,
	nodes ...forest.Node,
) forest.Store

SetupStore creates an orchard using a unique temporary file. After the run, database files are moved to a known location with the specified prefix to disambiguate between test runs.

Types

type Initializer

type Initializer func(path string) (forest.Store, error)

Initializer creates a store at the specified path.

Jump to

Keyboard shortcuts

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