restic/src/restic/backend/test/doc.go

39 lines
1.4 KiB
Go
Raw Normal View History

2017-05-14 08:58:09 +00:00
// Package test contains a test suite with benchmarks for restic backends.
//
// Overview
//
// For the test suite to work a few functions need to be implemented to create
// new config, create a backend, open it and run cleanup tasks afterwards. The
// Suite struct has fields for each function.
//
// So for a new backend, a Suite needs to be built with callback functions,
// then the methods RunTests() and RunBenchmarks() can be used to run the
// individual tests and benchmarks as subtests/subbenchmarks.
//
// Example
//
// Assuming a *Suite is returned by newTestSuite(), the tests and benchmarks
// can be run like this:
//
// func TestSuiteBackendMem(t *testing.T) {
// newTestSuite(t).RunTests(t)
// }
//
// func BenchmarkSuiteBackendMem(b *testing.B) {
// newTestSuite(b).RunBenchmarks(b)
// }
//
// Add new tests
//
// A new test or benchmark can be added by implementing a function with a name
// starting with BackendTest or BackendBenchmark. The first parameter is either
// a testing.TB or *testing.T (for tests), or a *testing.B (for benchmarks).
// The second parameter is a pointer to the test suite currently running
// (*Suite).
//
// The list of functions to run is contained in the file funcs.go, which is
// generated by generate_test_list.go. To regenerate that file, use go generate
// restic/backend/test. Test/benchmark functions are run in the order they are
// defined.
package test