Documentation ¶
Overview ¶
Package test provides common Camlistore test objects.
Index ¶
- Variables
- func BrokenTest(t *testing.T)
- func DependencyErrorOrSkip(t *testing.T)
- func Diff(a, b []byte) string
- func MustRunCmd(t testing.TB, c *exec.Cmd) string
- func NewLogger(t *testing.T, prefix string) *log.Logger
- func RunCmd(c *exec.Cmd) (output string, err error)
- func TLog(t testing.TB) func()
- func WaitFor(condition func() bool, maxWait, checkInterval time.Duration) bool
- type Blob
- func (tb *Blob) AssertMatches(t *testing.T, sb blob.SizedRef)
- func (tb *Blob) BlobRef() blob.Ref
- func (tb *Blob) BlobRefSlice() []blob.Ref
- func (tb *Blob) MustUpload(t *testing.T, ds blobserver.BlobReceiver)
- func (tb *Blob) Reader() io.Reader
- func (tb *Blob) Size() int64
- func (tb *Blob) SizedRef() blob.SizedRef
- type FakeIndex
- func (fi *FakeIndex) AddClaim(owner, permanode blob.Ref, claimType, attr, value string)
- func (fi *FakeIndex) AddMeta(br blob.Ref, camliType string, size uint32)
- func (fi *FakeIndex) AddSignerAttrValue(signer blob.Ref, attr, val string, latest blob.Ref)
- func (fi *FakeIndex) AppendClaims(dst []camtypes.Claim, permaNode blob.Ref, signerFilter blob.Ref, ...) ([]camtypes.Claim, error)
- func (fi *FakeIndex) EdgesTo(ref blob.Ref, opts *camtypes.EdgesToOpts) ([]*camtypes.Edge, error)
- func (fi *FakeIndex) EnumerateBlobMeta(ctx *context.Context, ch chan<- camtypes.BlobMeta) error
- func (fi *FakeIndex) ExistingFileSchemas(bytesRef blob.Ref) ([]blob.Ref, error)
- func (fi *FakeIndex) GetBlobMeta(br blob.Ref) (camtypes.BlobMeta, error)
- func (fi *FakeIndex) GetDirMembers(dir blob.Ref, dest chan<- blob.Ref, limit int) error
- func (fi *FakeIndex) GetFileInfo(fileRef blob.Ref) (camtypes.FileInfo, error)
- func (fi *FakeIndex) GetImageInfo(fileRef blob.Ref) (camtypes.ImageInfo, error)
- func (fi *FakeIndex) GetMediaTags(fileRef blob.Ref) (tags map[string]string, err error)
- func (fi *FakeIndex) GetRecentPermanodes(dest chan<- camtypes.RecentPermanode, owner blob.Ref, limit int, ...) error
- func (fi *FakeIndex) KeyId(blob.Ref) (string, error)
- func (fi *FakeIndex) LastTime() time.Time
- func (fi *FakeIndex) PathLookup(signer, base blob.Ref, suffix string, at time.Time) (*camtypes.Path, error)
- func (fi *FakeIndex) PathsLookup(signer, base blob.Ref, suffix string) ([]*camtypes.Path, error)
- func (fi *FakeIndex) PathsOfSignerTarget(signer, target blob.Ref) ([]*camtypes.Path, error)
- func (fi *FakeIndex) PermanodeOfSignerAttrValue(signer blob.Ref, attr, val string) (blob.Ref, error)
- func (fi *FakeIndex) SearchPermanodesWithAttr(dest chan<- blob.Ref, request *camtypes.PermanodeByAttrRequest) error
- type Fetcher
- type Loader
- func (ld *Loader) AllHandlers() (map[string]string, map[string]interface{})
- func (ld *Loader) BaseURL() string
- func (ld *Loader) FindHandlerByType(handlerType string) (prefix string, handler interface{}, err error)
- func (ld *Loader) GetHandler(prefix string) (interface{}, error)
- func (ld *Loader) GetHandlerType(prefix string) string
- func (ld *Loader) GetStorage(prefix string) (blobserver.Storage, error)
- func (ld *Loader) MyPrefix() string
- func (ld *Loader) SetStorage(prefix string, s blobserver.Storage)
- type World
- func (w *World) Addr() string
- func (w *World) CamliSourceRoot() string
- func (w *World) ClientIdentity() string
- func (w *World) Cmd(binary string, args ...string) *exec.Cmd
- func (w *World) CmdWithEnv(binary string, env []string, args ...string) *exec.Cmd
- func (w *World) NewPermanode(t *testing.T) blob.Ref
- func (w *World) Ping() error
- func (w *World) SearchHandlerPath() string
- func (w *World) SecretRingFile() string
- func (w *World) ServerBaseURL() string
- func (w *World) Start() error
- func (w *World) Stop()
Constants ¶
This section is empty.
Variables ¶
var ClockOrigin = time.Unix(1322443956, 123456)
Functions ¶
func BrokenTest ¶
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 ¶
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 ¶
MustRunCmd wraps RunCmd, failing t if RunCmd returns an error.
func RunCmd ¶
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.
Types ¶
type Blob ¶
type Blob struct {
Contents string // the contents of the blob
}
Blob is a utility class for unit tests.
func (*Blob) BlobRefSlice ¶
func (*Blob) MustUpload ¶
func (tb *Blob) MustUpload(t *testing.T, ds blobserver.BlobReceiver)
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) AddSignerAttrValue ¶
func (*FakeIndex) AppendClaims ¶
func (*FakeIndex) EnumerateBlobMeta ¶
func (*FakeIndex) ExistingFileSchemas ¶
func (*FakeIndex) GetBlobMeta ¶
func (*FakeIndex) GetDirMembers ¶
func (*FakeIndex) GetFileInfo ¶
func (*FakeIndex) GetImageInfo ¶
func (*FakeIndex) GetMediaTags ¶
func (*FakeIndex) GetRecentPermanodes ¶
func (*FakeIndex) PathLookup ¶
func (*FakeIndex) PathsLookup ¶
func (*FakeIndex) PathsOfSignerTarget ¶
func (*FakeIndex) PermanodeOfSignerAttrValue ¶
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 { memory.Storage // 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 }
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) ReceiveBlob ¶
type Loader ¶
type Loader struct {
// contains filtered or unexported fields
}
func (*Loader) AllHandlers ¶
func (*Loader) FindHandlerByType ¶
func (*Loader) GetHandler ¶
func (*Loader) GetHandlerType ¶
func (*Loader) GetStorage ¶
func (ld *Loader) GetStorage(prefix string) (blobserver.Storage, error)
func (*Loader) SetStorage ¶
func (ld *Loader) SetStorage(prefix string, s blobserver.Storage)
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 ¶
GetWorld returns (creating if necessary) a test singleton world. It calls Fatal on the provided test if there are problems.
func GetWorldMaybe ¶
GetWorldMaybe returns the current World. It might be nil.
func NewWorld ¶
NewWorld returns a new test world. It requires that GOPATH is set to find the "camlistore.org" root.
func WorldFromConfig ¶
WorldFromConfig returns a new test world based on the given configuration file. This cfg is the server config relative to pkg/test/testdata. It requires that GOPATH is set to find the "camlistore.org" root.
func (*World) CamliSourceRoot ¶
CamliSourceRoot returns the root of the source tree.
func (*World) ClientIdentity ¶
ClientIdentity returns the GPG identity to use in World tests, suitable for setting in CAMLI_KEYID.
func (*World) CmdWithEnv ¶
func (*World) SearchHandlerPath ¶
SearchHandlerPath returns the path to the search handler, with trailing slash.
func (*World) SecretRingFile ¶
SecretRingFile returns the GnuPG secret ring, suitable for setting in CAMLI_SECRET_RING.
func (*World) ServerBaseURL ¶
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
Package asserts provides a bad implementation of test predicate helpers.
|
Package asserts provides a bad implementation of test predicate helpers. |
Package dockertest contains helper functions for setting up and tearing down docker containers to aid in testing.
|
Package dockertest contains helper functions for setting up and tearing down docker containers to aid in testing. |