Rename backend test functions

This commit is contained in:
Alexander Neumann 2017-05-12 21:06:49 +02:00
parent 85e4831198
commit fbf2462325
3 changed files with 29 additions and 29 deletions

View File

@ -5,16 +5,16 @@ import (
"testing" "testing"
) )
var TestFunctions = []struct { var testFunctions = []struct {
Name string Name string
Fn func(t testing.TB, suite *Suite) Fn func(t testing.TB, suite *Suite)
}{ }{
{"CreateWithConfig", TestCreateWithConfig}, {"CreateWithConfig", BackendTestCreateWithConfig},
{"Location", TestLocation}, {"Location", BackendTestLocation},
{"Config", TestConfig}, {"Config", BackendTestConfig},
{"Load", TestLoad}, {"Load", BackendTestLoad},
{"Save", TestSave}, {"Save", BackendTestSave},
{"SaveFilenames", TestSaveFilenames}, {"SaveFilenames", BackendTestSaveFilenames},
{"Backend", TestBackend}, {"Backend", BackendTestBackend},
{"Delete", TestDelete}, {"Delete", BackendTestDelete},
} }

View File

@ -30,12 +30,12 @@ import (
"testing" "testing"
) )
var TestFunctions = []struct { var testFunctions = []struct {
Name string Name string
Fn func(t testing.TB, suite *Suite) Fn func(t testing.TB, suite *Suite)
}{ }{
{{ range $f := .Funcs -}} {{ range $f := .Funcs -}}
{"{{ $f }}", Test{{ $f }},}, {"{{ $f }}", BackendTest{{ $f }},},
{{ end }} {{ end }}
} }
` `
@ -55,7 +55,7 @@ func errx(err error) {
os.Exit(1) os.Exit(1)
} }
var funcRegex = regexp.MustCompile(`^func\s+Test(.+)\s*\(`) var funcRegex = regexp.MustCompile(`^func\s+BackendTest(.+)\s*\(`)
func findTestFunctions() (funcs []string) { func findTestFunctions() (funcs []string) {
f, err := os.Open(*testFile) f, err := os.Open(*testFile)

View File

@ -51,7 +51,7 @@ func (s *Suite) RunTests(t *testing.T) {
be := s.create(t) be := s.create(t)
s.close(t, be) s.close(t, be)
for _, test := range TestFunctions { for _, test := range testFunctions {
t.Run(test.Name, func(t *testing.T) { t.Run(test.Name, func(t *testing.T) {
test.Fn(t, s) test.Fn(t, s)
}) })
@ -90,9 +90,9 @@ func (s *Suite) close(t testing.TB, be restic.Backend) {
} }
} }
// TestCreateWithConfig tests that creating a backend in a location which already // BackendTestCreateWithConfig tests that creating a backend in a location which already
// has a config file fails. // has a config file fails.
func TestCreateWithConfig(t testing.TB, s *Suite) { func BackendTestCreateWithConfig(t testing.TB, s *Suite) {
b := s.open(t) b := s.open(t)
defer s.close(t, b) defer s.close(t, b)
@ -112,8 +112,8 @@ func TestCreateWithConfig(t testing.TB, s *Suite) {
} }
} }
// TestLocation tests that a location string is returned. // BackendTestLocation tests that a location string is returned.
func TestLocation(t testing.TB, s *Suite) { func BackendTestLocation(t testing.TB, s *Suite) {
b := s.open(t) b := s.open(t)
defer s.close(t, b) defer s.close(t, b)
@ -123,8 +123,8 @@ func TestLocation(t testing.TB, s *Suite) {
} }
} }
// TestConfig saves and loads a config from the backend. // BackendTestConfig saves and loads a config from the backend.
func TestConfig(t testing.TB, s *Suite) { func BackendTestConfig(t testing.TB, s *Suite) {
b := s.open(t) b := s.open(t)
defer s.close(t, b) defer s.close(t, b)
@ -156,8 +156,8 @@ func TestConfig(t testing.TB, s *Suite) {
} }
} }
// TestLoad tests the backend's Load function. // BackendTestLoad tests the backend's Load function.
func TestLoad(t testing.TB, s *Suite) { func BackendTestLoad(t testing.TB, s *Suite) {
b := s.open(t) b := s.open(t)
defer s.close(t, b) defer s.close(t, b)
@ -284,8 +284,8 @@ func (ec errorCloser) Close() error {
return errors.New("forbidden method close was called") return errors.New("forbidden method close was called")
} }
// TestSave tests saving data in the backend. // BackendTestSave tests saving data in the backend.
func TestSave(t testing.TB, s *Suite) { func BackendTestSave(t testing.TB, s *Suite) {
b := s.open(t) b := s.open(t)
defer s.close(t, b) defer s.close(t, b)
var id restic.ID var id restic.ID
@ -384,8 +384,8 @@ var filenameTests = []struct {
}, },
} }
// TestSaveFilenames tests saving data with various file names in the backend. // BackendTestSaveFilenames tests saving data with various file names in the backend.
func TestSaveFilenames(t testing.TB, s *Suite) { func BackendTestSaveFilenames(t testing.TB, s *Suite) {
b := s.open(t) b := s.open(t)
defer s.close(t, b) defer s.close(t, b)
@ -433,8 +433,8 @@ func store(t testing.TB, b restic.Backend, tpe restic.FileType, data []byte) res
return h return h
} }
// TestBackend tests all functions of the backend. // BackendTestBackend tests all functions of the backend.
func TestBackend(t testing.TB, s *Suite) { func BackendTestBackend(t testing.TB, s *Suite) {
b := s.open(t) b := s.open(t)
defer s.close(t, b) defer s.close(t, b)
@ -567,8 +567,8 @@ func TestBackend(t testing.TB, s *Suite) {
} }
} }
// TestDelete tests the Delete function. // BackendTestDelete tests the Delete function.
func TestDelete(t testing.TB, s *Suite) { func BackendTestDelete(t testing.TB, s *Suite) {
if !test.TestCleanupTempDirs { if !test.TestCleanupTempDirs {
t.Skipf("not removing backend, TestCleanupTempDirs is false") t.Skipf("not removing backend, TestCleanupTempDirs is false")
} }