localblobstore_testlib

package
v0.0.0-...-ff5f600 Latest Latest
Warning

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

Go to latest
Published: Apr 30, 2016 License: BSD-3-Clause Imports: 12 Imported by: 0

Documentation

Overview

A test library for localblobstores.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddRetrieveAndDelete

func AddRetrieveAndDelete(t *testing.T, ctx *context.T, bs localblobstore.BlobStore, testDirName string)

AddRetrieveAndDelete() tests adding, retrieving, and deleting blobs from a blobstore bs. One can't retrieve or delete something that hasn't been created, so it's all done in one routine. If testDirName is non-empty, the blobstore is assumed to be accessible in the file system, and its files are checked.

func CreateAndResume

func CreateAndResume(t *testing.T, ctx *context.T, bs localblobstore.BlobStore)

CreateAndResume() tests that it's possible to create a blob with NewBlobWriter(), immediately close it, and then resume writing with ResumeBlobWriter. This test is called out because syncbase does this, and it exposed a bug in the reader code, which could not cope with a request to read starting at the very end of a file, thus returning no bytes.

func WriteViaChunks

func WriteViaChunks(t *testing.T, ctx *context.T, bs [2]localblobstore.BlobStore)

WriteViaChunks() tests that a large blob in one blob store can be transmitted to another incrementally, without transferring chunks already in the other blob store.

Types

type RandReader

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

A RandReader contains a pointer to a rand.Read, and a size limit. Its pointers implement the Read() method from io.Reader, which yields bytes obtained from the random number generator.

func NewRandReader

func NewRandReader(seed int64, limit int, insertInterval int, eofErr error) *RandReader

NewRandReader() returns a new RandReader with the specified seed and size limit. It yields eofErr when the end of the stream is reached. If insertInterval is non-zero, a zero byte is inserted into the stream every insertInterval bytes, before resuming getting bytes from the random number generator.

func (*RandReader) Read

func (r *RandReader) Read(buf []byte) (n int, err error)

Read() implements the io.Reader Read() method for *RandReader.

Jump to

Keyboard shortcuts

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