Documentation
¶
Overview ¶
Package drivertest provides a conformance test for implementations of driver.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Asset ¶
Asset loads and returns the asset for the given name. It returns an error if the asset could not be found or could not be loaded.
func AssetDir ¶
AssetDir returns the file names below a certain directory embedded in the file by go-bindata. For example if you run go-bindata on data/... and data contains the following hierarchy:
data/
foo.txt
img/
a.png
b.png
then AssetDir("data") would return []string{"foo.txt", "img"} AssetDir("data/img") would return []string{"a.png", "b.png"} AssetDir("foo.txt") and AssetDir("notexist") would return an error AssetDir("") will return []string{"data"}.
func RunBenchmarks ¶ added in v0.9.0
RunBenchmarks runs benchmarks for provider implementations of blob.
func RunConformanceTests ¶
func RunConformanceTests(t *testing.T, newHarness HarnessMaker, asTests []AsTest)
RunConformanceTests runs conformance tests for provider implementations of blob.
Types ¶
type AsTest ¶
type AsTest interface {
// Name should return a descriptive name for the test.
Name() string
// BucketCheck will be called to allow verification of Bucket.As.
BucketCheck(b *blob.Bucket) error
// ErrorCheck will be called to allow verification of Bucket.ErrorAs.
ErrorCheck(b *blob.Bucket, err error) error
// BeforeRead will be passed directly to ReaderOptions as part of reading
// a test blob.
BeforeRead(as func(interface{}) bool) error
// BeforeWrite will be passed directly to WriterOptions as part of creating
// a test blob.
BeforeWrite(as func(interface{}) bool) error
// BeforeCopy will be passed directly to CopyOptions as part of copying
// the test blob.
BeforeCopy(as func(interface{}) bool) error
// BeforeList will be passed directly to ListOptions as part of listing the
// test blob.
BeforeList(as func(interface{}) bool) error
// AttributesCheck will be called after fetching the test blob's attributes.
// It should call attrs.As and verify the results.
AttributesCheck(attrs *blob.Attributes) error
// ReaderCheck will be called after creating a blob.Reader.
// It should call r.As and verify the results.
ReaderCheck(r *blob.Reader) error
// ListObjectCheck will be called after calling List with the test object's
// name as the Prefix. It should call o.As and verify the results.
ListObjectCheck(o *blob.ListObject) error
}
AsTest represents a test of As functionality. The conformance test:
- Calls BucketCheck.
- Creates a blob in a directory, using BeforeWrite as a WriterOption.
- Fetches the blob's attributes and calls AttributeCheck.
- Creates a Reader for the blob using BeforeReader as a ReaderOption, and calls ReaderCheck with the resulting Reader.
- Calls List using BeforeList as a ListOption, with Delimiter set so that only the directory is returned, and calls ListObjectCheck on the single directory list entry returned.
- Calls List using BeforeList as a ListOption, and calls ListObjectCheck on the single blob entry returned.
- Tries to read a non-existent blob, and calls ErrorCheck with the error.
- Makes a copy of the blob, using BeforeCopy as a CopyOption.
For example, an AsTest might set a provider-specific field to a custom value in BeforeWrite, and then verify the custom value was returned in AttributesCheck and/or ReaderCheck.
type Harness ¶
type Harness interface {
// MakeDriver creates a driver.Bucket to test.
// Multiple calls to MakeDriver during a test run must refer to the
// same storage bucket; i.e., a blob created using one driver.Bucket must
// be readable by a subsequent driver.Bucket.
MakeDriver(ctx context.Context) (driver.Bucket, error)
// HTTPClient should return an unauthorized *http.Client, or nil.
// Required if the provider supports SignedURL.
HTTPClient() *http.Client
// Close closes resources used by the harness.
Close()
}
Harness descibes the functionality test harnesses must provide to run conformance tests.