TestDBPrefix is used to prefix temporary database names during tests.
const TestDBPrefix = "kivik$"
AllDocsIndex is the default index for _all_docs
var AllDocsIndex = kivik.Index{ Name: "_all_docs", Type: "special", Definition: map[string]interface{}{"fields": []map[string]string{{"_id": "asc"}}}, }
func Body(str string, args ...interface{}) io.ReadCloser
Body turns a string into a read closer, useful as a request or attachment body.
func DSN3(t *testing.T) string
DSN3 returns a testing DSN from the environment for CouchDB 3.x.
func GetClient(t *testing.T) *kivik.Client
GetClient returns a connection to a CouchDB client, for testing.
func GetNoAuthClient(t *testing.T) *kivik.Client
GetNoAuthClient returns an unauthenticated connection to a CouchDB client, for testing.
func NoAuthDSN(t *testing.T) string
NoAuthDSN returns a testing DSN with credentials stripped.
func Register(name string, fn testFunc)
Register registers a test to be run for the given test suite. rw should be true if the test writes to the database.
func Retry(fn func() error) error
Retry will try an operation up to maxRetries times, in case of one of the following failures. All other failures are returned.
func RunSubtests(ctx *Context)
RunSubtests executes the requested suites of tests against the client.
func TestDBName(t *testing.T) string
TestDBName generates a randomized string suitable for a database name for testing.
Context is a collection of client connections with different security access.
type Context struct { // RW is true if we should run read-write tests. RW bool // Admin is a client connection with database admin privileges. Admin *kivik.Client // NoAuth isa client connection with no authentication. NoAuth *kivik.Client // Config is the suite config Config SuiteConfig // T is the *testing.T value T *testing.T }
func (c *Context) Bool(key string) bool
Bool returns a bool from the config.
func (c *Context) CheckError(err error) (match bool, success bool)
CheckError compares the error's status code with that expected.
func (c *Context) Child(t *testing.T) *Context
Child returns a shallow copy of itself with a new t.
func (c *Context) DestroyDB(name string)
DestroyDB cleans up the specified DB after tests run
func (c *Context) Errorf(format string, args ...interface{})
Errorf is a wrapper around t.Errorf()
func (c *Context) Fatalf(format string, args ...interface{})
Fatalf is a wrapper around t.Fatalf()
func (c *Context) Int(key string) int
Int returns an int from the config.
func (c *Context) IntSlice(key string) []int
IntSlice returns a []int from config.
func (c *Context) Interface(key string) interface{}
Interface returns the configuration value as an interface{}.
func (c *Context) IsExpected(err error) bool
IsExpected checks the error against the expected status, and returns true if they match.
func (c *Context) IsExpectedSuccess(err error) bool
IsExpectedSuccess combines IsExpected() and IsSuccess(), returning true only if there is no error, and no error was expected.
func (c *Context) IsSet(key string) bool
IsSet returns true if the value is set in the configuration.
func (c *Context) IsSuccess(err error) bool
IsSuccess is similar to IsExpected, except for its return value. This method returns true if the expected status == 0, regardless of the error.
func (c *Context) Logf(format string, args ...interface{})
Logf is a wrapper around t.Logf()
func (c *Context) MustBeSet(key string)
MustBeSet ends the test with a failure if the config key is not set.
func (c *Context) MustBool(key string) bool
MustBool returns a bool, or fails if the value is unset.
func (c *Context) MustInt(key string) int
MustInt returns an int from the config, or fails if the value is unset.
func (c *Context) MustIntSlice(key string) []int
MustIntSlice returns a []int, or fails if the value is unset.
func (c *Context) MustInterface(key string) interface{}
MustInterface returns an interface{} from the config, or fails if the value is unset.
func (c *Context) MustString(key string) string
MustString returns a string from config, or fails if the value is unset.
func (c *Context) MustStringSlice(key string) []string
MustStringSlice returns a string slice, or fails if the value is unset.
func (c *Context) Options(key string) kivik.Option
Options returns an options map value.
func (c *Context) Parallel()
Parallel is a wrapper around t.Parallel()
func (c *Context) Run(name string, fn testFunc)
Run wraps t.Run()
func (c *Context) RunAdmin(fn testFunc)
RunAdmin runs the test function iff c.Admin is set.
func (c *Context) RunNoAuth(fn testFunc)
RunNoAuth runs the test function iff c.NoAuth is set.
func (c *Context) RunRO(fn testFunc)
RunRO runs the test function iff c.RW is false. Note that unlike RunRW, this does not start a new subtest. This should usually be run in conjunction with RunRW, to run only RO or RW tests, in situations where running both would be redundant.
func (c *Context) RunRW(fn testFunc)
RunRW runs the test function iff c.RW is true.
func (c *Context) Skip()
Skip will skip the currently running test if configuration dictates.
func (c *Context) Skipf(format string, args ...interface{})
Skipf is a wrapper around t.Skipf()
func (c *Context) String(key string) string
String returns a string from config.
func (c *Context) StringSlice(key string) []string
StringSlice returns a string slice from the config.
func (c *Context) TestDB() string
TestDB creates a test database, regesters a cleanup function to destroy it, and returns its name.
func (c *Context) TestDBName() string
TestDBName generates a randomized string suitable for a database name for testing.
SuiteConfig represents the configuration for a test suite.
type SuiteConfig map[string]interface{}
func (c SuiteConfig) Bool(t *testing.T, key string) bool
Bool returns the boolean value of the key.
func (c SuiteConfig) Int(t *testing.T, key string) int
Int returns an int.
func (c SuiteConfig) Interface(t *testing.T, key string) interface{}
Interface returns the configuration value as an interface{}.
func (c SuiteConfig) Skip(t *testing.T)
Skip will skip the currently running test if configuration dictates.
func (c SuiteConfig) String(t *testing.T, key string) string
String returns a string.
func (c SuiteConfig) StringSlice(t *testing.T, key string) []string
StringSlice returns a string slice.