test

package
v0.0.0-...-8462f15 Latest Latest
Warning

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

Go to latest
Published: Mar 2, 2014 License: Apache-2.0 Imports: 25 Imported by: 0

Documentation

Overview

Package test provides common Camlistore test objects.

Index

Constants

This section is empty.

Variables

View Source
var ClockOrigin = time.Unix(1322443956, 123456)

Functions

func BrokenTest

func BrokenTest(t *testing.T)

BrokenTest marks the test as broken and calls t.Skip, unless the environment variable RUN_BROKEN_TESTS is set to 1 (or some other boolean true value).

func DependencyErrorOrSkip

func DependencyErrorOrSkip(t *testing.T)

DependencyErrorOrSkip is called when a test's dependency isn't found. It either skips the current test (if SKIP_DEP_TESTS is set), or calls t.Error with an error.

func Diff

func Diff(a, b []byte) string

Diff returns the unified diff (from running "diff -u") or returns an error string.

func MustRunCmd

func MustRunCmd(t *testing.T, c *exec.Cmd) string

MustRunCmd wraps RunCmd, failing t if RunCmd returns an error.

func RunCmd

func RunCmd(c *exec.Cmd) (output string, err error)

RunCmd runs c (which is assumed to be something short-lived, like a camput or camget command), capturing its stdout for return, and also capturing its stderr, just in the case of errors. If there's an error, the return error fully describes the command and all output.

func TLog

func TLog(t TB) func()

TLog changes the log package's output to log to t and returns a function to reset it back to stderr.

func WaitFor

func WaitFor(condition func() bool, maxWait, checkInterval time.Duration) bool

WaitFor returns true if condition returns true before maxWait. It is checked immediately, and then every checkInterval.

Types

type Blob

type Blob struct {
	Contents string // the contents of the blob
}

Blob is a utility class for unit tests.

func (*Blob) AssertMatches

func (tb *Blob) AssertMatches(t *testing.T, sb blob.SizedRef)

func (*Blob) BlobRef

func (tb *Blob) BlobRef() blob.Ref

func (*Blob) BlobRefSlice

func (tb *Blob) BlobRefSlice() []blob.Ref

func (*Blob) MustUpload

func (tb *Blob) MustUpload(t *testing.T, ds blobserver.BlobReceiver)

func (*Blob) Reader

func (tb *Blob) Reader() io.Reader

func (*Blob) Size

func (tb *Blob) Size() int64

func (*Blob) SizedRef

func (tb *Blob) SizedRef() blob.SizedRef

type FakeIndex

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

A FakeIndex implements parts of search.Index and provides methods to controls the results, such as AddMeta, AddClaim, AddSignerAttrValue.

func NewFakeIndex

func NewFakeIndex() *FakeIndex

func (*FakeIndex) AddClaim

func (fi *FakeIndex) AddClaim(owner, permanode blob.Ref, claimType, attr, value string)

func (*FakeIndex) AddMeta

func (fi *FakeIndex) AddMeta(br blob.Ref, camliType string, size int64)

func (*FakeIndex) AddSignerAttrValue

func (fi *FakeIndex) AddSignerAttrValue(signer blob.Ref, attr, val string, latest blob.Ref)

func (*FakeIndex) AppendClaims

func (fi *FakeIndex) AppendClaims(dst []camtypes.Claim, permaNode blob.Ref,
	signerFilter blob.Ref,
	attrFilter string) ([]camtypes.Claim, error)

func (*FakeIndex) EdgesTo

func (fi *FakeIndex) EdgesTo(ref blob.Ref, opts *camtypes.EdgesToOpts) ([]*camtypes.Edge, error)

func (*FakeIndex) EnumerateBlobMeta

func (fi *FakeIndex) EnumerateBlobMeta(ctx *context.Context, ch chan<- camtypes.BlobMeta) error

func (*FakeIndex) ExistingFileSchemas

func (fi *FakeIndex) ExistingFileSchemas(bytesRef blob.Ref) ([]blob.Ref, error)

func (*FakeIndex) GetBlobMeta

func (fi *FakeIndex) GetBlobMeta(br blob.Ref) (camtypes.BlobMeta, error)

func (*FakeIndex) GetDirMembers

func (fi *FakeIndex) GetDirMembers(dir blob.Ref, dest chan<- blob.Ref, limit int) error

func (*FakeIndex) GetFileInfo

func (fi *FakeIndex) GetFileInfo(fileRef blob.Ref) (camtypes.FileInfo, error)

func (*FakeIndex) GetImageInfo

func (fi *FakeIndex) GetImageInfo(fileRef blob.Ref) (camtypes.ImageInfo, error)

func (*FakeIndex) GetRecentPermanodes

func (fi *FakeIndex) GetRecentPermanodes(dest chan<- camtypes.RecentPermanode, owner blob.Ref, limit int, before time.Time) error

func (*FakeIndex) KeyId

func (fi *FakeIndex) KeyId(blob.Ref) (string, error)

func (*FakeIndex) LastTime

func (fi *FakeIndex) LastTime() time.Time

func (*FakeIndex) PathLookup

func (fi *FakeIndex) PathLookup(signer, base blob.Ref, suffix string, at time.Time) (*camtypes.Path, error)

func (*FakeIndex) PathsLookup

func (fi *FakeIndex) PathsLookup(signer, base blob.Ref, suffix string) ([]*camtypes.Path, error)

func (*FakeIndex) PathsOfSignerTarget

func (fi *FakeIndex) PathsOfSignerTarget(signer, target blob.Ref) ([]*camtypes.Path, error)

func (*FakeIndex) PermanodeOfSignerAttrValue

func (fi *FakeIndex) PermanodeOfSignerAttrValue(signer blob.Ref, attr, val string) (blob.Ref, error)

func (*FakeIndex) SearchPermanodesWithAttr

func (fi *FakeIndex) SearchPermanodesWithAttr(dest chan<- blob.Ref, request *camtypes.PermanodeByAttrRequest) error

TODO(mpl): write real tests

type Fetcher

type Fetcher struct {

	// ReceiveErr optionally returns the error to return on receive.
	ReceiveErr error

	// FetchErr, if non-nil, specifies the error to return on the next fetch call.
	// If it returns nil, fetches proceed as normal.
	FetchErr func() error
	// contains filtered or unexported fields
}

Fetcher is an in-memory implementation of the blobserver Storage interface. It started as just a fetcher and grew. It also includes other convenience methods for testing.

func (*Fetcher) AddBlob

func (tf *Fetcher) AddBlob(b *Blob)

func (*Fetcher) BlobContents

func (tf *Fetcher) BlobContents(br blob.Ref) (contents string, ok bool)

func (*Fetcher) BlobrefStrings

func (tf *Fetcher) BlobrefStrings() []string

BlobrefStrings returns the sorted stringified blobrefs stored in this fetcher.

func (*Fetcher) EnumerateBlobs

func (tf *Fetcher) EnumerateBlobs(ctx *context.Context, dest chan<- blob.SizedRef, after string, limit int) error

func (*Fetcher) Fetch

func (tf *Fetcher) Fetch(ref blob.Ref) (file types.ReadSeekCloser, size uint32, err error)

func (*Fetcher) FetchStreaming

func (tf *Fetcher) FetchStreaming(ref blob.Ref) (file io.ReadCloser, size uint32, err error)

func (*Fetcher) NumBlobs

func (tf *Fetcher) NumBlobs() int

func (*Fetcher) ReceiveBlob

func (tf *Fetcher) ReceiveBlob(br blob.Ref, source io.Reader) (blob.SizedRef, error)

func (*Fetcher) RemoveBlobs

func (tf *Fetcher) RemoveBlobs(blobs []blob.Ref) error

func (*Fetcher) StatBlobs

func (tf *Fetcher) StatBlobs(dest chan<- blob.SizedRef, blobs []blob.Ref) error

type Loader

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

func NewLoader

func NewLoader() *Loader

NewLoader

func (*Loader) FindHandlerByType

func (ld *Loader) FindHandlerByType(handlerType string) (prefix string, handler interface{}, err error)

func (*Loader) GetHandler

func (ld *Loader) GetHandler(prefix string) (interface{}, error)

func (*Loader) GetHandlerType

func (ld *Loader) GetHandlerType(prefix string) string

func (*Loader) GetStorage

func (ld *Loader) GetStorage(prefix string) (blobserver.Storage, error)

func (*Loader) MyPrefix

func (ld *Loader) MyPrefix() string

func (*Loader) SetStorage

func (ld *Loader) SetStorage(prefix string, s blobserver.Storage)

type TB

type TB interface {
	Error(args ...interface{})
	Errorf(format string, args ...interface{})
	Fail()
	FailNow()
	Failed() bool
	Fatal(args ...interface{})
	Fatalf(format string, args ...interface{})
	Log(args ...interface{})
	Logf(format string, args ...interface{})
	Skip(args ...interface{})
	SkipNow()
	Skipf(format string, args ...interface{})
	Skipped() bool
}

TB is a copy of Go 1.2's testing.TB.

type World

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

World defines an integration test world.

It's used to run the actual Camlistore binaries (camlistored, camput, camget, camtool, etc) together in large tests, including building them, finding them, and wiring them up in an isolated way.

func GetWorld

func GetWorld(t *testing.T) *World

GetWorld returns (creating if necessary) a test singleton world. It calls Fatal on the provided test if there are problems.

func GetWorldMaybe

func GetWorldMaybe(t *testing.T) *World

GetWorldMaybe returns the current World. It might be nil.

func NewWorld

func NewWorld() (*World, error)

NewWorld returns a new test world. It requires that GOPATH is set to find the "camlistore.org" root.

func (*World) Addr

func (w *World) Addr() string

func (*World) ClientIdentity

func (w *World) ClientIdentity() string

ClientIdentity returns the GPG identity to use in World tests, suitable for setting in CAMLI_CLIENT_IDENTITY.

func (*World) Cmd

func (w *World) Cmd(binary string, args ...string) *exec.Cmd

func (*World) CmdWithEnv

func (w *World) CmdWithEnv(binary string, env []string, args ...string) *exec.Cmd

func (*World) NewPermanode

func (w *World) NewPermanode(t *testing.T) blob.Ref

func (*World) Ping

func (w *World) Ping() error

Ping returns an error if the world's camlistored is not running.

func (*World) SearchHandlerPath

func (w *World) SearchHandlerPath() string

SearchHandlerPath returns the path to the search handler, with trailing slash.

func (*World) SecretRingFile

func (w *World) SecretRingFile() string

SecretRingFile returns the GnuPG secret ring, suitable for setting in CAMLI_SECRET_RING.

func (*World) ServerBaseURL

func (w *World) ServerBaseURL() string

func (*World) Start

func (w *World) Start() error

Start builds the Camlistore binaries and starts a server.

func (*World) Stop

func (w *World) Stop()

Directories

Path Synopsis
Package asserts provides a bad implementation of test predicate helpers.
Package asserts provides a bad implementation of test predicate helpers.

Jump to

Keyboard shortcuts

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