2
2
mirror of https://github.com/octoleo/restic.git synced 2024-12-23 11:28:54 +00:00

Add "Test" prefix to backend test functions

This commit is contained in:
Alexander Neumann 2016-01-23 19:12:02 +01:00
parent e4f2e4a203
commit f05a32509e
13 changed files with 94 additions and 94 deletions

View File

@ -13,75 +13,75 @@ func TestLocalBackendCreate(t *testing.T) {
if SkipMessage != "" {
t.Skip(SkipMessage)
}
test.Create(t)
test.TestCreate(t)
}
func TestLocalBackendOpen(t *testing.T) {
if SkipMessage != "" {
t.Skip(SkipMessage)
}
test.Open(t)
test.TestOpen(t)
}
func TestLocalBackendCreateWithConfig(t *testing.T) {
if SkipMessage != "" {
t.Skip(SkipMessage)
}
test.CreateWithConfig(t)
test.TestCreateWithConfig(t)
}
func TestLocalBackendLocation(t *testing.T) {
if SkipMessage != "" {
t.Skip(SkipMessage)
}
test.Location(t)
test.TestLocation(t)
}
func TestLocalBackendConfig(t *testing.T) {
if SkipMessage != "" {
t.Skip(SkipMessage)
}
test.Config(t)
test.TestConfig(t)
}
func TestLocalBackendGetReader(t *testing.T) {
if SkipMessage != "" {
t.Skip(SkipMessage)
}
test.GetReader(t)
test.TestGetReader(t)
}
func TestLocalBackendLoad(t *testing.T) {
if SkipMessage != "" {
t.Skip(SkipMessage)
}
test.Load(t)
test.TestLoad(t)
}
func TestLocalBackendWrite(t *testing.T) {
if SkipMessage != "" {
t.Skip(SkipMessage)
}
test.Write(t)
test.TestWrite(t)
}
func TestLocalBackendGeneric(t *testing.T) {
func TestLocalBackendBackend(t *testing.T) {
if SkipMessage != "" {
t.Skip(SkipMessage)
}
test.Generic(t)
test.TestBackend(t)
}
func TestLocalBackendDelete(t *testing.T) {
if SkipMessage != "" {
t.Skip(SkipMessage)
}
test.Delete(t)
test.TestDelete(t)
}
func TestLocalBackendCleanup(t *testing.T) {
if SkipMessage != "" {
t.Skip(SkipMessage)
}
test.Cleanup(t)
test.TestCleanup(t)
}

View File

@ -13,75 +13,75 @@ func TestMemBackendCreate(t *testing.T) {
if SkipMessage != "" {
t.Skip(SkipMessage)
}
test.Create(t)
test.TestCreate(t)
}
func TestMemBackendOpen(t *testing.T) {
if SkipMessage != "" {
t.Skip(SkipMessage)
}
test.Open(t)
test.TestOpen(t)
}
func TestMemBackendCreateWithConfig(t *testing.T) {
if SkipMessage != "" {
t.Skip(SkipMessage)
}
test.CreateWithConfig(t)
test.TestCreateWithConfig(t)
}
func TestMemBackendLocation(t *testing.T) {
if SkipMessage != "" {
t.Skip(SkipMessage)
}
test.Location(t)
test.TestLocation(t)
}
func TestMemBackendConfig(t *testing.T) {
if SkipMessage != "" {
t.Skip(SkipMessage)
}
test.Config(t)
test.TestConfig(t)
}
func TestMemBackendGetReader(t *testing.T) {
if SkipMessage != "" {
t.Skip(SkipMessage)
}
test.GetReader(t)
test.TestGetReader(t)
}
func TestMemBackendLoad(t *testing.T) {
if SkipMessage != "" {
t.Skip(SkipMessage)
}
test.Load(t)
test.TestLoad(t)
}
func TestMemBackendWrite(t *testing.T) {
if SkipMessage != "" {
t.Skip(SkipMessage)
}
test.Write(t)
test.TestWrite(t)
}
func TestMemBackendGeneric(t *testing.T) {
func TestMemBackendBackend(t *testing.T) {
if SkipMessage != "" {
t.Skip(SkipMessage)
}
test.Generic(t)
test.TestBackend(t)
}
func TestMemBackendDelete(t *testing.T) {
if SkipMessage != "" {
t.Skip(SkipMessage)
}
test.Delete(t)
test.TestDelete(t)
}
func TestMemBackendCleanup(t *testing.T) {
if SkipMessage != "" {
t.Skip(SkipMessage)
}
test.Cleanup(t)
test.TestCleanup(t)
}

View File

@ -13,75 +13,75 @@ func TestS3BackendCreate(t *testing.T) {
if SkipMessage != "" {
t.Skip(SkipMessage)
}
test.Create(t)
test.TestCreate(t)
}
func TestS3BackendOpen(t *testing.T) {
if SkipMessage != "" {
t.Skip(SkipMessage)
}
test.Open(t)
test.TestOpen(t)
}
func TestS3BackendCreateWithConfig(t *testing.T) {
if SkipMessage != "" {
t.Skip(SkipMessage)
}
test.CreateWithConfig(t)
test.TestCreateWithConfig(t)
}
func TestS3BackendLocation(t *testing.T) {
if SkipMessage != "" {
t.Skip(SkipMessage)
}
test.Location(t)
test.TestLocation(t)
}
func TestS3BackendConfig(t *testing.T) {
if SkipMessage != "" {
t.Skip(SkipMessage)
}
test.Config(t)
test.TestConfig(t)
}
func TestS3BackendGetReader(t *testing.T) {
if SkipMessage != "" {
t.Skip(SkipMessage)
}
test.GetReader(t)
test.TestGetReader(t)
}
func TestS3BackendLoad(t *testing.T) {
if SkipMessage != "" {
t.Skip(SkipMessage)
}
test.Load(t)
test.TestLoad(t)
}
func TestS3BackendWrite(t *testing.T) {
if SkipMessage != "" {
t.Skip(SkipMessage)
}
test.Write(t)
test.TestWrite(t)
}
func TestS3BackendGeneric(t *testing.T) {
func TestS3BackendBackend(t *testing.T) {
if SkipMessage != "" {
t.Skip(SkipMessage)
}
test.Generic(t)
test.TestBackend(t)
}
func TestS3BackendDelete(t *testing.T) {
if SkipMessage != "" {
t.Skip(SkipMessage)
}
test.Delete(t)
test.TestDelete(t)
}
func TestS3BackendCleanup(t *testing.T) {
if SkipMessage != "" {
t.Skip(SkipMessage)
}
test.Cleanup(t)
test.TestCleanup(t)
}

View File

@ -13,75 +13,75 @@ func TestSftpBackendCreate(t *testing.T) {
if SkipMessage != "" {
t.Skip(SkipMessage)
}
test.Create(t)
test.TestCreate(t)
}
func TestSftpBackendOpen(t *testing.T) {
if SkipMessage != "" {
t.Skip(SkipMessage)
}
test.Open(t)
test.TestOpen(t)
}
func TestSftpBackendCreateWithConfig(t *testing.T) {
if SkipMessage != "" {
t.Skip(SkipMessage)
}
test.CreateWithConfig(t)
test.TestCreateWithConfig(t)
}
func TestSftpBackendLocation(t *testing.T) {
if SkipMessage != "" {
t.Skip(SkipMessage)
}
test.Location(t)
test.TestLocation(t)
}
func TestSftpBackendConfig(t *testing.T) {
if SkipMessage != "" {
t.Skip(SkipMessage)
}
test.Config(t)
test.TestConfig(t)
}
func TestSftpBackendGetReader(t *testing.T) {
if SkipMessage != "" {
t.Skip(SkipMessage)
}
test.GetReader(t)
test.TestGetReader(t)
}
func TestSftpBackendLoad(t *testing.T) {
if SkipMessage != "" {
t.Skip(SkipMessage)
}
test.Load(t)
test.TestLoad(t)
}
func TestSftpBackendWrite(t *testing.T) {
if SkipMessage != "" {
t.Skip(SkipMessage)
}
test.Write(t)
test.TestWrite(t)
}
func TestSftpBackendGeneric(t *testing.T) {
func TestSftpBackendBackend(t *testing.T) {
if SkipMessage != "" {
t.Skip(SkipMessage)
}
test.Generic(t)
test.TestBackend(t)
}
func TestSftpBackendDelete(t *testing.T) {
if SkipMessage != "" {
t.Skip(SkipMessage)
}
test.Delete(t)
test.TestDelete(t)
}
func TestSftpBackendCleanup(t *testing.T) {
if SkipMessage != "" {
t.Skip(SkipMessage)
}
test.Cleanup(t)
test.TestCleanup(t)
}

View File

@ -13,75 +13,75 @@ func TestTestBackendCreate(t *testing.T) {
if SkipMessage != "" {
t.Skip(SkipMessage)
}
test.Create(t)
test.TestCreate(t)
}
func TestTestBackendOpen(t *testing.T) {
if SkipMessage != "" {
t.Skip(SkipMessage)
}
test.Open(t)
test.TestOpen(t)
}
func TestTestBackendCreateWithConfig(t *testing.T) {
if SkipMessage != "" {
t.Skip(SkipMessage)
}
test.CreateWithConfig(t)
test.TestCreateWithConfig(t)
}
func TestTestBackendLocation(t *testing.T) {
if SkipMessage != "" {
t.Skip(SkipMessage)
}
test.Location(t)
test.TestLocation(t)
}
func TestTestBackendConfig(t *testing.T) {
if SkipMessage != "" {
t.Skip(SkipMessage)
}
test.Config(t)
test.TestConfig(t)
}
func TestTestBackendGetReader(t *testing.T) {
if SkipMessage != "" {
t.Skip(SkipMessage)
}
test.GetReader(t)
test.TestGetReader(t)
}
func TestTestBackendLoad(t *testing.T) {
if SkipMessage != "" {
t.Skip(SkipMessage)
}
test.Load(t)
test.TestLoad(t)
}
func TestTestBackendWrite(t *testing.T) {
if SkipMessage != "" {
t.Skip(SkipMessage)
}
test.Write(t)
test.TestWrite(t)
}
func TestTestBackendGeneric(t *testing.T) {
func TestTestBackendBackend(t *testing.T) {
if SkipMessage != "" {
t.Skip(SkipMessage)
}
test.Generic(t)
test.TestBackend(t)
}
func TestTestBackendDelete(t *testing.T) {
if SkipMessage != "" {
t.Skip(SkipMessage)
}
test.Delete(t)
test.TestDelete(t)
}
func TestTestBackendCleanup(t *testing.T) {
if SkipMessage != "" {
t.Skip(SkipMessage)
}
test.Cleanup(t)
test.TestCleanup(t)
}

View File

@ -39,7 +39,7 @@ var SkipMessage string
{{ range $f := .Funcs }}
func Test{{ $prefix }}{{ $f }}(t *testing.T){
if SkipMessage != "" { t.Skip(SkipMessage) }
test.{{ $f }}(t)
test.Test{{ $f }}(t)
}
{{ end }}
@ -60,7 +60,7 @@ func errx(err error) {
os.Exit(1)
}
var funcRegex = regexp.MustCompile(`^func\s+([A-Z].*)\s*\(`)
var funcRegex = regexp.MustCompile(`^func\s+Test(.+)\s*\(`)
func findTestFunctions() (funcs []string) {
f, err := os.Open(*testFile)

View File

@ -70,8 +70,8 @@ func close(t testing.TB) {
but = nil
}
// Create creates a backend.
func Create(t testing.TB) {
// TestCreate creates a backend.
func TestCreate(t testing.TB) {
if CreateFn == nil {
t.Fatalf("CreateFn not set!")
}
@ -90,8 +90,8 @@ func Create(t testing.TB) {
}
}
// Open opens a previously created backend.
func Open(t testing.TB) {
// TestOpen opens a previously created backend.
func TestOpen(t testing.TB) {
if OpenFn == nil {
t.Fatalf("OpenFn not set!")
}
@ -107,9 +107,9 @@ func Open(t testing.TB) {
}
}
// CreateWithConfig tests that creating a backend in a location which already
// TestCreateWithConfig tests that creating a backend in a location which already
// has a config file fails.
func CreateWithConfig(t testing.TB) {
func TestCreateWithConfig(t testing.TB) {
if CreateFn == nil {
t.Fatalf("CreateFn not set")
}
@ -133,8 +133,8 @@ func CreateWithConfig(t testing.TB) {
}
}
// Location tests that a location string is returned.
func Location(t testing.TB) {
// TestLocation tests that a location string is returned.
func TestLocation(t testing.TB) {
b := open(t)
defer close(t)
@ -144,8 +144,8 @@ func Location(t testing.TB) {
}
}
// Config saves and loads a config from the backend.
func Config(t testing.TB) {
// TestConfig saves and loads a config from the backend.
func TestConfig(t testing.TB) {
b := open(t)
defer close(t)
@ -196,8 +196,8 @@ func Config(t testing.TB) {
}
}
// GetReader tests various ways the GetReader function can be called.
func GetReader(t testing.TB) {
// TestGetReader tests various ways the GetReader function can be called.
func TestGetReader(t testing.TB) {
b := open(t)
defer close(t)
@ -245,8 +245,8 @@ func GetReader(t testing.TB) {
OK(t, b.Remove(backend.Data, id.String()))
}
// Load tests the backend's Load function.
func Load(t testing.TB) {
// TestLoad tests the backend's Load function.
func TestLoad(t testing.TB) {
b := open(t)
defer close(t)
@ -325,8 +325,8 @@ func Load(t testing.TB) {
OK(t, b.Remove(backend.Data, id.String()))
}
// Write tests writing data to the backend.
func Write(t testing.TB) {
// TestWrite tests writing data to the backend.
func TestWrite(t testing.TB) {
b := open(t)
defer close(t)
@ -410,8 +410,8 @@ func read(t testing.TB, rd io.Reader, expectedData []byte) {
}
}
// Generic tests all functions of the backend.
func Generic(t testing.TB) {
// TestBackend tests all functions of the backend.
func TestBackend(t testing.TB) {
b := open(t)
defer close(t)
@ -523,7 +523,7 @@ func Generic(t testing.TB) {
}
// remove content if requested
if TestCleanup {
if TestCleanupTempDirs {
for _, test := range testStrings {
id, err := backend.ParseID(test.id)
OK(t, err)
@ -541,8 +541,8 @@ func Generic(t testing.TB) {
}
}
// Delete tests the Delete function.
func Delete(t testing.TB) {
// TestDelete tests the Delete function.
func TestDelete(t testing.TB) {
b := open(t)
defer close(t)
@ -557,14 +557,14 @@ func Delete(t testing.TB) {
}
}
// Cleanup runs the cleanup function after all tests are run.
func Cleanup(t testing.TB) {
// TestCleanup runs the cleanup function after all tests are run.
func TestCleanup(t testing.TB) {
if CleanupFn == nil {
t.Log("CleanupFn function not set")
return
}
if !TestCleanup {
if !TestCleanupTempDirs {
t.Logf("not cleaning up backend")
return
}

View File

@ -60,7 +60,7 @@ func cmdMount(t testing.TB, global GlobalOptions, dir string, ready, done chan s
cmd := &CmdMount{global: &global, ready: ready, done: done}
OK(t, cmd.Execute([]string{dir}))
if TestCleanup {
if TestCleanupTempDirs {
RemoveAll(t, dir)
}
}

View File

@ -178,7 +178,7 @@ func configureRestic(t testing.TB, cache, repo string) GlobalOptions {
}
func cleanupTempdir(t testing.TB, tempdir string) {
if !TestCleanup {
if !TestCleanupTempDirs {
t.Logf("leaving temporary directory %v used for test", tempdir)
return
}
@ -209,7 +209,7 @@ func withTestEnvironment(t testing.TB, f func(*testEnvironment, GlobalOptions))
f(&env, configureRestic(t, env.cache, env.repo))
if !TestCleanup {
if !TestCleanupTempDirs {
t.Logf("leaving temporary directory %v used for test", tempdir)
return
}

View File

@ -145,7 +145,7 @@ func TestNodeRestoreAt(t *testing.T) {
OK(t, err)
defer func() {
if TestCleanup {
if TestCleanupTempDirs {
RemoveAll(t, tempdir)
} else {
t.Logf("leaving tempdir at %v", tempdir)

View File

@ -15,7 +15,7 @@ import (
var (
TestPassword = getStringVar("RESTIC_TEST_PASSWORD", "geheim")
TestCleanup = getBoolVar("RESTIC_TEST_CLEANUP", true)
TestCleanupTempDirs = getBoolVar("RESTIC_TEST_CLEANUP", true)
TestTempDir = getStringVar("RESTIC_TEST_TMPDIR", "")
RunIntegrationTest = getBoolVar("RESTIC_TEST_INTEGRATION", true)
RunFuseTest = getBoolVar("RESTIC_TEST_FUSE", true)
@ -70,7 +70,7 @@ func SetupRepo() *repository.Repository {
}
func TeardownRepo(repo *repository.Repository) {
if !TestCleanup {
if !TestCleanupTempDirs {
l := repo.Backend().(*local.Local)
fmt.Printf("leaving local backend at %s\n", l.Location())
return

View File

@ -158,7 +158,7 @@ func WithTestEnvironment(t testing.TB, repoFixture string, f func(repodir string
f(filepath.Join(tempdir, "repo"))
if !TestCleanup {
if !TestCleanupTempDirs {
t.Logf("leaving temporary directory %v used for test", tempdir)
return
}

View File

@ -49,7 +49,7 @@ func createTempDir(t *testing.T) string {
func TestTree(t *testing.T) {
dir := createTempDir(t)
defer func() {
if TestCleanup {
if TestCleanupTempDirs {
RemoveAll(t, dir)
}
}()