2
2
mirror of https://github.com/octoleo/restic.git synced 2024-11-22 21:05:10 +00:00

tests: Add documentation

This commit is contained in:
Alexander Neumann 2017-05-14 10:58:09 +02:00
parent 90c1608d88
commit 77a55fbe5c
3 changed files with 45 additions and 1 deletions

View File

@ -24,6 +24,8 @@ func remove(t testing.TB, be restic.Backend, h restic.Handle) {
}
}
// BackendBenchmarkLoadFile benchmarks the Load() method of a backend by
// loading a complete file.
func BackendBenchmarkLoadFile(t *testing.B, s *Suite) {
be := s.open(t)
defer s.close(t, be)
@ -62,6 +64,8 @@ func BackendBenchmarkLoadFile(t *testing.B, s *Suite) {
}
}
// BackendBenchmarkLoadPartialFile benchmarks the Load() method of a backend by
// loading the remainder of a file starting at a given offset.
func BackendBenchmarkLoadPartialFile(t *testing.B, s *Suite) {
be := s.open(t)
defer s.close(t, be)
@ -103,6 +107,8 @@ func BackendBenchmarkLoadPartialFile(t *testing.B, s *Suite) {
}
}
// BackendBenchmarkLoadPartialFileOffset benchmarks the Load() method of a
// backend by loading a number of bytes of a file starting at a given offset.
func BackendBenchmarkLoadPartialFileOffset(t *testing.B, s *Suite) {
be := s.open(t)
defer s.close(t, be)
@ -145,6 +151,7 @@ func BackendBenchmarkLoadPartialFileOffset(t *testing.B, s *Suite) {
}
}
// BackendBenchmarkSave benchmarks the Save() method of a backend.
func BackendBenchmarkSave(t *testing.B, s *Suite) {
be := s.open(t)
defer s.close(t, be)

View File

@ -0,0 +1,38 @@
// 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

View File

@ -1,4 +1,3 @@
// Package test contains a test suite for restic backends.
package test
import (