import "gocloud.dev/blob/drivertest"
Package drivertest provides a conformance test for implementations of driver.
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.
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"}.
AssetNames returns the names of the assets.
RunBenchmarks runs benchmarks for driver implementations of blob.
func RunConformanceTests(t *testing.T, newHarness HarnessMaker, asTests []AsTest)
RunConformanceTests runs conformance tests for driver implementations of blob.
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 // BeforeSign will be passed directly to SignedURLOptions as part of // generating a signed URL to the test blob. BeforeSign(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: 1. Calls BucketCheck. 2. Creates a blob in a directory, using BeforeWrite as a WriterOption. 3. Fetches the blob's attributes and calls AttributeCheck. 4. Creates a Reader for the blob using BeforeReader as a ReaderOption,
and calls ReaderCheck with the resulting Reader.
5. 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.
6. Calls List using BeforeList as a ListOption, and calls ListObjectCheck
on the single blob entry returned.
7. Tries to read a non-existent blob, and calls ErrorCheck with the error. 8. Makes a copy of the blob, using BeforeCopy as a CopyOption. 9. Calls SignedURL using BeforeSign as a SignedURLOption for each supported
signing method (i.e. GET, PUT and DELETE).
For example, an AsTest might set a driver-specific field to a custom value in BeforeWrite, and then verify the custom value was returned in AttributesCheck and/or ReaderCheck.
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) // MakeDriverForNonexistentBucket creates a driver.Bucket for a nonexistent // bucket. If that concept doesn't make sense for a driver, return (nil, nil). MakeDriverForNonexistentBucket(ctx context.Context) (driver.Bucket, error) // HTTPClient should return an unauthorized *http.Client, or nil. // Required if the service 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.
HarnessMaker describes functions that construct a harness for running tests. It is called exactly once per test; Harness.Close() will be called when the test is complete.
Package drivertest imports 23 packages (graph). Updated 2020-12-08. Refresh now. Tools for package owners.