package drivertest
import "gocloud.dev/pubsub/drivertest"
Package drivertest provides a conformance test for implementations of driver.
Index ¶
- func RunConformanceTests(t *testing.T, newHarness HarnessMaker, asTests []AsTest)
- type AsTest
- type Harness
- type HarnessMaker
Functions ¶
func RunConformanceTests ¶
func RunConformanceTests(t *testing.T, newHarness HarnessMaker, asTests []AsTest)
RunConformanceTests runs conformance tests for provider implementations of pubsub.
Types ¶
type AsTest ¶
type AsTest interface { // Name should return a descriptive name for the test. Name() string // TopicCheck will be called to allow verifcation of Topic.As. TopicCheck(t *pubsub.Topic) error // SubscriptionCheck will be called to allow verification of Subscription.As. SubscriptionCheck(s *pubsub.Subscription) error }
AsTest represents a test of As functionality. The conformance test: 1. Calls TopicCheck. 2. Calls SubscriptionCheck.
type Harness ¶
type Harness interface { // CreateTopic creates a new topic in the provider and returns a driver.Topic for testing. // The topic may have to be removed manually if the test is abruptly terminated or the network connection fails. CreateTopic(ctx context.Context, testName string) (dt driver.Topic, cleanup func(), err error) // MakeNonexistentTopic makes a driver.Topic referencing a topic that // does not exist. MakeNonexistentTopic(ctx context.Context) (driver.Topic, error) // CreateSubscription creates a new subscription in the provider, subscribed to the given topic, and returns // a driver.Subscription for testing. // The subscription may have to be cleaned up manually if the test is abruptly terminated or the network connection // fails. CreateSubscription(ctx context.Context, t driver.Topic, testName string) (ds driver.Subscription, cleanup func(), err error) // MakeNonexistentSubscription makes a driver.Subscription referencing a // subscription that does not exist. MakeNonexistentSubscription(ctx context.Context) (driver.Subscription, error) // Close closes resources used by the harness, but does not call Close // on the Topics and Subscriptions generated by the Harness. Close() }
Harness descibes the functionality test harnesses must provide to run conformance tests.
type HarnessMaker ¶
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.
Source Files ¶
drivertest.go
- Version
- v0.9.0
- Published
- Jan 15, 2019
- Platform
- js/wasm
- Imports
- 10 packages
- Last checked
- 5 days ago –
Tools for package owners.