test

package
v0.0.0-...-4b1b879 Latest Latest
Warning

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

Go to latest
Published: Jul 29, 2013 License: Apache-2.0 Imports: 22 Imported by: 0

Documentation

Overview

Package test provides common Camlistore test objects.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

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 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 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 blobref.SizedBlobRef)

func (*Blob) BlobRef

func (tb *Blob) BlobRef() *blobref.BlobRef

func (*Blob) BlobRefSlice

func (tb *Blob) BlobRefSlice() []*blobref.BlobRef

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

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 *blobref.BlobRef, claimType, attr, value string)

func (*FakeIndex) AddMeta

func (fi *FakeIndex) AddMeta(blob *blobref.BlobRef, mime string, size int64)

func (*FakeIndex) AddSignerAttrValue

func (fi *FakeIndex) AddSignerAttrValue(signer *blobref.BlobRef, attr, val string, latest *blobref.BlobRef)

func (*FakeIndex) EdgesTo

func (fi *FakeIndex) EdgesTo(ref *blobref.BlobRef, opts *search.EdgesToOpts) ([]*search.Edge, error)

func (*FakeIndex) ExistingFileSchemas

func (fi *FakeIndex) ExistingFileSchemas(bytesRef *blobref.BlobRef) ([]*blobref.BlobRef, error)

func (*FakeIndex) GetBlobMIMEType

func (fi *FakeIndex) GetBlobMIMEType(blob *blobref.BlobRef) (mime string, size int64, err error)

func (*FakeIndex) GetFileInfo

func (fi *FakeIndex) GetFileInfo(fileRef *blobref.BlobRef) (*search.FileInfo, error)

func (*FakeIndex) GetImageInfo

func (fi *FakeIndex) GetImageInfo(fileRef *blobref.BlobRef) (*search.ImageInfo, error)

func (*FakeIndex) GetOwnerClaims

func (fi *FakeIndex) GetOwnerClaims(permaNode, owner *blobref.BlobRef) (search.ClaimList, error)

func (*FakeIndex) GetRecentPermanodes

func (fi *FakeIndex) GetRecentPermanodes(dest chan *search.Result, owner *blobref.BlobRef, limit int) error

func (*FakeIndex) PathLookup

func (fi *FakeIndex) PathLookup(signer, base *blobref.BlobRef, suffix string, at time.Time) (*search.Path, error)

func (*FakeIndex) PathsLookup

func (fi *FakeIndex) PathsLookup(signer, base *blobref.BlobRef, suffix string) ([]*search.Path, error)

func (*FakeIndex) PathsOfSignerTarget

func (fi *FakeIndex) PathsOfSignerTarget(signer, target *blobref.BlobRef) ([]*search.Path, error)

func (*FakeIndex) PermanodeOfSignerAttrValue

func (fi *FakeIndex) PermanodeOfSignerAttrValue(signer *blobref.BlobRef, attr, val string) (*blobref.BlobRef, error)

func (*FakeIndex) SearchPermanodesWithAttr

func (fi *FakeIndex) SearchPermanodesWithAttr(dest chan<- *blobref.BlobRef, request *search.PermanodeByAttrRequest) error

TODO(mpl): write real tests

type Fetcher

type Fetcher struct {
	blobserver.SimpleBlobHubPartitionMap
	// 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 *blobref.BlobRef) (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(dest chan<- blobref.SizedBlobRef,
	after string,
	limit int,
	wait time.Duration) error

func (*Fetcher) Fetch

func (tf *Fetcher) Fetch(ref *blobref.BlobRef) (file types.ReadSeekCloser, size int64, err error)

func (*Fetcher) FetchStreaming

func (tf *Fetcher) FetchStreaming(ref *blobref.BlobRef) (file io.ReadCloser, size int64, err error)

func (*Fetcher) ReceiveBlob

func (tf *Fetcher) ReceiveBlob(br *blobref.BlobRef, source io.Reader) (blobref.SizedBlobRef, error)

func (*Fetcher) RemoveBlobs

func (tf *Fetcher) RemoveBlobs(blobs []*blobref.BlobRef) error

func (*Fetcher) StatBlobs

func (tf *Fetcher) StatBlobs(dest chan<- blobref.SizedBlobRef, blobs []*blobref.BlobRef, wait time.Duration) error

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 the 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 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) Cmd

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

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