Remove all dot-imports

This commit is contained in:
Herbert
2017-10-02 15:06:39 +02:00
parent 1b5242b4f9
commit 3473c3f7b6
31 changed files with 598 additions and 601 deletions

View File

@@ -13,7 +13,7 @@ import (
"github.com/restic/restic/internal/repository"
"github.com/restic/restic/internal/restic"
. "github.com/restic/restic/internal/test"
"github.com/restic/restic/internal/test"
)
const (
@@ -56,7 +56,7 @@ func waitForMount(t testing.TB, dir string) {
func testRunMount(t testing.TB, gopts GlobalOptions, dir string) {
opts := MountOptions{}
OK(t, runMount(opts, gopts, []string{dir}))
test.OK(t, runMount(opts, gopts, []string{dir}))
}
func testRunUmount(t testing.TB, gopts GlobalOptions, dir string) {
@@ -75,10 +75,10 @@ func testRunUmount(t testing.TB, gopts GlobalOptions, dir string) {
func listSnapshots(t testing.TB, dir string) []string {
snapshotsDir, err := os.Open(filepath.Join(dir, "snapshots"))
OK(t, err)
test.OK(t, err)
names, err := snapshotsDir.Readdirnames(-1)
OK(t, err)
OK(t, snapshotsDir.Close())
test.OK(t, err)
test.OK(t, snapshotsDir.Close())
return names
}
@@ -98,7 +98,7 @@ func checkSnapshots(t testing.TB, global GlobalOptions, repo *repository.Reposit
namesInSnapshots := listSnapshots(t, mountpoint)
t.Logf("found %v snapshots in fuse mount: %v", len(namesInSnapshots), namesInSnapshots)
Assert(t,
test.Assert(t,
expectedSnapshotsInFuseDir == len(namesInSnapshots),
"Invalid number of snapshots: expected %d, got %d", expectedSnapshotsInFuseDir, len(namesInSnapshots))
@@ -119,7 +119,7 @@ func checkSnapshots(t testing.TB, global GlobalOptions, repo *repository.Reposit
for _, id := range snapshotIDs {
snapshot, err := restic.LoadSnapshot(context.TODO(), repo, id)
OK(t, err)
test.OK(t, err)
ts := snapshot.Time.Format(time.RFC3339)
present, ok := namesMap[ts]
@@ -143,12 +143,12 @@ func checkSnapshots(t testing.TB, global GlobalOptions, repo *repository.Reposit
}
for name, present := range namesMap {
Assert(t, present, "Directory %s is present in fuse dir but is not a snapshot", name)
test.Assert(t, present, "Directory %s is present in fuse dir but is not a snapshot", name)
}
}
func TestMount(t *testing.T) {
if !RunFuseTest {
if !test.RunFuseTest {
t.Skip("Skipping fuse tests")
}
@@ -158,19 +158,19 @@ func TestMount(t *testing.T) {
testRunInit(t, env.gopts)
repo, err := OpenRepository(env.gopts)
OK(t, err)
test.OK(t, err)
// We remove the mountpoint now to check that cmdMount creates it
RemoveAll(t, env.mountpoint)
test.RemoveAll(t, env.mountpoint)
checkSnapshots(t, env.gopts, repo, env.mountpoint, env.repo, []restic.ID{}, 0)
SetupTarTestFixture(t, env.testdata, filepath.Join("testdata", "backup-data.tar.gz"))
test.SetupTarTestFixture(t, env.testdata, filepath.Join("testdata", "backup-data.tar.gz"))
// first backup
testRunBackup(t, []string{env.testdata}, BackupOptions{}, env.gopts)
snapshotIDs := testRunList(t, "snapshots", env.gopts)
Assert(t, len(snapshotIDs) == 1,
test.Assert(t, len(snapshotIDs) == 1,
"expected one snapshot, got %v", snapshotIDs)
checkSnapshots(t, env.gopts, repo, env.mountpoint, env.repo, snapshotIDs, 2)
@@ -178,7 +178,7 @@ func TestMount(t *testing.T) {
// second backup, implicit incremental
testRunBackup(t, []string{env.testdata}, BackupOptions{}, env.gopts)
snapshotIDs = testRunList(t, "snapshots", env.gopts)
Assert(t, len(snapshotIDs) == 2,
test.Assert(t, len(snapshotIDs) == 2,
"expected two snapshots, got %v", snapshotIDs)
checkSnapshots(t, env.gopts, repo, env.mountpoint, env.repo, snapshotIDs, 3)
@@ -187,24 +187,24 @@ func TestMount(t *testing.T) {
bopts := BackupOptions{Parent: snapshotIDs[0].String()}
testRunBackup(t, []string{env.testdata}, bopts, env.gopts)
snapshotIDs = testRunList(t, "snapshots", env.gopts)
Assert(t, len(snapshotIDs) == 3,
test.Assert(t, len(snapshotIDs) == 3,
"expected three snapshots, got %v", snapshotIDs)
checkSnapshots(t, env.gopts, repo, env.mountpoint, env.repo, snapshotIDs, 4)
}
func TestMountSameTimestamps(t *testing.T) {
if !RunFuseTest {
if !test.RunFuseTest {
t.Skip("Skipping fuse tests")
}
env, cleanup := withTestEnvironment(t)
defer cleanup()
SetupTarTestFixture(t, env.base, filepath.Join("testdata", "repo-same-timestamps.tar.gz"))
test.SetupTarTestFixture(t, env.base, filepath.Join("testdata", "repo-same-timestamps.tar.gz"))
repo, err := OpenRepository(env.gopts)
OK(t, err)
test.OK(t, err)
ids := []restic.ID{
restic.TestParseID("280303689e5027328889a06d718b729e96a1ce6ae9ef8290bff550459ae611ee"),

View File

@@ -11,7 +11,7 @@ import (
"github.com/restic/restic/internal/options"
"github.com/restic/restic/internal/repository"
. "github.com/restic/restic/internal/test"
"github.com/restic/restic/internal/test"
)
type dirEntry struct {
@@ -174,14 +174,14 @@ type testEnvironment struct {
// withTestEnvironment creates a test environment and returns a cleanup
// function which removes it.
func withTestEnvironment(t testing.TB) (env *testEnvironment, cleanup func()) {
if !RunIntegrationTest {
if !test.RunIntegrationTest {
t.Skip("integration tests disabled")
}
repository.TestUseLowSecurityKDFParameters(t)
tempdir, err := ioutil.TempDir(TestTempDir, "restic-test-")
OK(t, err)
tempdir, err := ioutil.TempDir(test.TestTempDir, "restic-test-")
test.OK(t, err)
env = &testEnvironment{
base: tempdir,
@@ -191,17 +191,17 @@ func withTestEnvironment(t testing.TB) (env *testEnvironment, cleanup func()) {
mountpoint: filepath.Join(tempdir, "mount"),
}
OK(t, os.MkdirAll(env.mountpoint, 0700))
OK(t, os.MkdirAll(env.testdata, 0700))
OK(t, os.MkdirAll(env.cache, 0700))
OK(t, os.MkdirAll(env.repo, 0700))
test.OK(t, os.MkdirAll(env.mountpoint, 0700))
test.OK(t, os.MkdirAll(env.testdata, 0700))
test.OK(t, os.MkdirAll(env.cache, 0700))
test.OK(t, os.MkdirAll(env.repo, 0700))
env.gopts = GlobalOptions{
Repo: env.repo,
Quiet: true,
CacheDir: env.cache,
ctx: context.Background(),
password: TestPassword,
password: test.TestPassword,
stdout: os.Stdout,
stderr: os.Stderr,
extended: make(options.Options),
@@ -211,11 +211,11 @@ func withTestEnvironment(t testing.TB) (env *testEnvironment, cleanup func()) {
globalOptions = env.gopts
cleanup = func() {
if !TestCleanupTempDirs {
if !test.TestCleanupTempDirs {
t.Logf("leaving temporary directory %v used for test", tempdir)
return
}
RemoveAll(t, tempdir)
test.RemoveAll(t, tempdir)
}
return env, cleanup

View File

@@ -17,13 +17,12 @@ import (
"testing"
"time"
"github.com/restic/restic/internal/errors"
"github.com/restic/restic/internal/restic"
"github.com/restic/restic/internal/debug"
"github.com/restic/restic/internal/errors"
"github.com/restic/restic/internal/filter"
"github.com/restic/restic/internal/repository"
. "github.com/restic/restic/internal/test"
"github.com/restic/restic/internal/restic"
"github.com/restic/restic/internal/test"
)
func parseIDsFromReader(t testing.TB, rd io.Reader) restic.IDs {
@@ -47,13 +46,13 @@ func testRunInit(t testing.TB, opts GlobalOptions) {
repository.TestUseLowSecurityKDFParameters(t)
restic.TestSetLockTimeout(t, 0)
OK(t, runInit(opts, nil))
test.OK(t, runInit(opts, nil))
t.Logf("repository initialized at %v", opts.Repo)
}
func testRunBackup(t testing.TB, target []string, opts BackupOptions, gopts GlobalOptions) {
t.Logf("backing up %v", target)
OK(t, runBackup(opts, gopts, target))
test.OK(t, runBackup(opts, gopts, target))
}
func testRunList(t testing.TB, tpe string, opts GlobalOptions) restic.IDs {
@@ -63,7 +62,7 @@ func testRunList(t testing.TB, tpe string, opts GlobalOptions) restic.IDs {
globalOptions.stdout = os.Stdout
}()
OK(t, runList(opts, []string{tpe}))
test.OK(t, runList(opts, []string{tpe}))
return parseIDsFromReader(t, buf)
}
@@ -78,7 +77,7 @@ func testRunRestoreLatest(t testing.TB, gopts GlobalOptions, dir string, paths [
Paths: paths,
}
OK(t, runRestore(opts, gopts, []string{"latest"}))
test.OK(t, runRestore(opts, gopts, []string{"latest"}))
}
func testRunRestoreExcludes(t testing.TB, gopts GlobalOptions, dir string, snapshotID restic.ID, excludes []string) {
@@ -87,7 +86,7 @@ func testRunRestoreExcludes(t testing.TB, gopts GlobalOptions, dir string, snaps
Exclude: excludes,
}
OK(t, runRestore(opts, gopts, []string{snapshotID.String()}))
test.OK(t, runRestore(opts, gopts, []string{snapshotID.String()}))
}
func testRunRestoreIncludes(t testing.TB, gopts GlobalOptions, dir string, snapshotID restic.ID, includes []string) {
@@ -96,7 +95,7 @@ func testRunRestoreIncludes(t testing.TB, gopts GlobalOptions, dir string, snaps
Include: includes,
}
OK(t, runRestore(opts, gopts, []string{snapshotID.String()}))
test.OK(t, runRestore(opts, gopts, []string{snapshotID.String()}))
}
func testRunCheck(t testing.TB, gopts GlobalOptions) {
@@ -104,7 +103,7 @@ func testRunCheck(t testing.TB, gopts GlobalOptions) {
ReadData: true,
CheckUnused: true,
}
OK(t, runCheck(opts, gopts, nil))
test.OK(t, runCheck(opts, gopts, nil))
}
func testRunCheckOutput(gopts GlobalOptions) (string, error) {
@@ -129,7 +128,7 @@ func testRunRebuildIndex(t testing.TB, gopts GlobalOptions) {
globalOptions.stdout = os.Stdout
}()
OK(t, runRebuildIndex(gopts))
test.OK(t, runRebuildIndex(gopts))
}
func testRunLs(t testing.TB, gopts GlobalOptions, snapshotID string) []string {
@@ -144,7 +143,7 @@ func testRunLs(t testing.TB, gopts GlobalOptions, snapshotID string) []string {
opts := LsOptions{}
OK(t, runLs(opts, gopts, []string{snapshotID}))
test.OK(t, runLs(opts, gopts, []string{snapshotID}))
return strings.Split(string(buf.Bytes()), "\n")
}
@@ -160,7 +159,7 @@ func testRunFind(t testing.TB, wantJSON bool, gopts GlobalOptions, pattern strin
opts := FindOptions{}
OK(t, runFind(opts, gopts, []string{pattern}))
test.OK(t, runFind(opts, gopts, []string{pattern}))
return buf.Bytes()
}
@@ -176,10 +175,10 @@ func testRunSnapshots(t testing.TB, gopts GlobalOptions) (newest *Snapshot, snap
opts := SnapshotOptions{}
OK(t, runSnapshots(opts, globalOptions, []string{}))
test.OK(t, runSnapshots(opts, globalOptions, []string{}))
snapshots := []Snapshot{}
OK(t, json.Unmarshal(buf.Bytes(), &snapshots))
test.OK(t, json.Unmarshal(buf.Bytes(), &snapshots))
snapmap = make(map[restic.ID]Snapshot, len(snapshots))
for _, sn := range snapshots {
@@ -193,11 +192,11 @@ func testRunSnapshots(t testing.TB, gopts GlobalOptions) (newest *Snapshot, snap
func testRunForget(t testing.TB, gopts GlobalOptions, args ...string) {
opts := ForgetOptions{}
OK(t, runForget(opts, gopts, args))
test.OK(t, runForget(opts, gopts, args))
}
func testRunPrune(t testing.TB, gopts GlobalOptions) {
OK(t, runPrune(gopts))
test.OK(t, runPrune(gopts))
}
func TestBackup(t *testing.T) {
@@ -210,18 +209,18 @@ func TestBackup(t *testing.T) {
t.Skipf("unable to find data file %q, skipping", datafile)
return
}
OK(t, err)
OK(t, fd.Close())
test.OK(t, err)
test.OK(t, fd.Close())
testRunInit(t, env.gopts)
SetupTarTestFixture(t, env.testdata, datafile)
test.SetupTarTestFixture(t, env.testdata, datafile)
opts := BackupOptions{}
// first backup
testRunBackup(t, []string{env.testdata}, opts, env.gopts)
snapshotIDs := testRunList(t, "snapshots", env.gopts)
Assert(t, len(snapshotIDs) == 1,
test.Assert(t, len(snapshotIDs) == 1,
"expected one snapshot, got %v", snapshotIDs)
testRunCheck(t, env.gopts)
@@ -230,7 +229,7 @@ func TestBackup(t *testing.T) {
// second backup, implicit incremental
testRunBackup(t, []string{env.testdata}, opts, env.gopts)
snapshotIDs = testRunList(t, "snapshots", env.gopts)
Assert(t, len(snapshotIDs) == 2,
test.Assert(t, len(snapshotIDs) == 2,
"expected two snapshots, got %v", snapshotIDs)
stat2 := dirStats(env.repo)
@@ -244,7 +243,7 @@ func TestBackup(t *testing.T) {
opts.Parent = snapshotIDs[0].String()
testRunBackup(t, []string{env.testdata}, opts, env.gopts)
snapshotIDs = testRunList(t, "snapshots", env.gopts)
Assert(t, len(snapshotIDs) == 3,
test.Assert(t, len(snapshotIDs) == 3,
"expected three snapshots, got %v", snapshotIDs)
stat3 := dirStats(env.repo)
@@ -258,7 +257,7 @@ func TestBackup(t *testing.T) {
restoredir := filepath.Join(env.base, fmt.Sprintf("restore%d", i))
t.Logf("restoring snapshot %v to %v", snapshotID.Str(), restoredir)
testRunRestore(t, env.gopts, restoredir, snapshotIDs[0])
Assert(t, directoriesEqualContents(env.testdata, filepath.Join(restoredir, "testdata")),
test.Assert(t, directoriesEqualContents(env.testdata, filepath.Join(restoredir, "testdata")),
"directories are not equal")
}
@@ -275,10 +274,10 @@ func TestBackupNonExistingFile(t *testing.T) {
t.Skipf("unable to find data file %q, skipping", datafile)
return
}
OK(t, err)
OK(t, fd.Close())
test.OK(t, err)
test.OK(t, fd.Close())
SetupTarTestFixture(t, env.testdata, datafile)
test.SetupTarTestFixture(t, env.testdata, datafile)
testRunInit(t, env.gopts)
globalOptions.stderr = ioutil.Discard
@@ -309,10 +308,10 @@ func TestBackupMissingFile1(t *testing.T) {
t.Skipf("unable to find data file %q, skipping", datafile)
return
}
OK(t, err)
OK(t, fd.Close())
test.OK(t, err)
test.OK(t, fd.Close())
SetupTarTestFixture(t, env.testdata, datafile)
test.SetupTarTestFixture(t, env.testdata, datafile)
testRunInit(t, env.gopts)
globalOptions.stderr = ioutil.Discard
@@ -331,7 +330,7 @@ func TestBackupMissingFile1(t *testing.T) {
t.Logf("in hook, removing test file testdata/0/0/9/37")
ranHook = true
OK(t, os.Remove(filepath.Join(env.testdata, "0", "0", "9", "37")))
test.OK(t, os.Remove(filepath.Join(env.testdata, "0", "0", "9", "37")))
})
opts := BackupOptions{}
@@ -339,7 +338,7 @@ func TestBackupMissingFile1(t *testing.T) {
testRunBackup(t, []string{env.testdata}, opts, env.gopts)
testRunCheck(t, env.gopts)
Assert(t, ranHook, "hook did not run")
test.Assert(t, ranHook, "hook did not run")
debug.RemoveHook("pipe.walk1")
}
@@ -353,10 +352,10 @@ func TestBackupMissingFile2(t *testing.T) {
t.Skipf("unable to find data file %q, skipping", datafile)
return
}
OK(t, err)
OK(t, fd.Close())
test.OK(t, err)
test.OK(t, fd.Close())
SetupTarTestFixture(t, env.testdata, datafile)
test.SetupTarTestFixture(t, env.testdata, datafile)
testRunInit(t, env.gopts)
@@ -376,7 +375,7 @@ func TestBackupMissingFile2(t *testing.T) {
t.Logf("in hook, removing test file testdata/0/0/9/37")
ranHook = true
OK(t, os.Remove(filepath.Join(env.testdata, "0", "0", "9", "37")))
test.OK(t, os.Remove(filepath.Join(env.testdata, "0", "0", "9", "37")))
})
opts := BackupOptions{}
@@ -384,7 +383,7 @@ func TestBackupMissingFile2(t *testing.T) {
testRunBackup(t, []string{env.testdata}, opts, env.gopts)
testRunCheck(t, env.gopts)
Assert(t, ranHook, "hook did not run")
test.Assert(t, ranHook, "hook did not run")
debug.RemoveHook("pipe.walk2")
}
@@ -398,10 +397,10 @@ func TestBackupChangedFile(t *testing.T) {
t.Skipf("unable to find data file %q, skipping", datafile)
return
}
OK(t, err)
OK(t, fd.Close())
test.OK(t, err)
test.OK(t, fd.Close())
SetupTarTestFixture(t, env.testdata, datafile)
test.SetupTarTestFixture(t, env.testdata, datafile)
testRunInit(t, env.gopts)
@@ -423,7 +422,7 @@ func TestBackupChangedFile(t *testing.T) {
t.Logf("in hook, modifying test file %v", modFile)
ranHook = true
OK(t, ioutil.WriteFile(modFile, []byte("modified"), 0600))
test.OK(t, ioutil.WriteFile(modFile, []byte("modified"), 0600))
})
opts := BackupOptions{}
@@ -431,7 +430,7 @@ func TestBackupChangedFile(t *testing.T) {
testRunBackup(t, []string{env.testdata}, opts, env.gopts)
testRunCheck(t, env.gopts)
Assert(t, ranHook, "hook did not run")
test.Assert(t, ranHook, "hook did not run")
debug.RemoveHook("archiver.SaveFile")
}
@@ -445,10 +444,10 @@ func TestBackupDirectoryError(t *testing.T) {
t.Skipf("unable to find data file %q, skipping", datafile)
return
}
OK(t, err)
OK(t, fd.Close())
test.OK(t, err)
test.OK(t, fd.Close())
SetupTarTestFixture(t, env.testdata, datafile)
test.SetupTarTestFixture(t, env.testdata, datafile)
testRunInit(t, env.gopts)
@@ -472,22 +471,22 @@ func TestBackupDirectoryError(t *testing.T) {
t.Logf("in hook, removing test file %v", testdir)
ranHook = true
OK(t, os.RemoveAll(testdir))
test.OK(t, os.RemoveAll(testdir))
})
testRunBackup(t, []string{filepath.Join(env.testdata, "0", "0")}, BackupOptions{}, env.gopts)
testRunCheck(t, env.gopts)
Assert(t, ranHook, "hook did not run")
test.Assert(t, ranHook, "hook did not run")
debug.RemoveHook("pipe.walk2")
snapshots := testRunList(t, "snapshots", env.gopts)
Assert(t, len(snapshots) > 0,
test.Assert(t, len(snapshots) > 0,
"no snapshots found in repo (%v)", datafile)
files := testRunLs(t, env.gopts, snapshots[0].String())
Assert(t, len(files) > 1, "snapshot is empty")
test.Assert(t, len(files) > 1, "snapshot is empty")
}
func includes(haystack []string, needle string) bool {
@@ -539,13 +538,13 @@ func TestBackupExclude(t *testing.T) {
for _, filename := range backupExcludeFilenames {
fp := filepath.Join(datadir, filename)
OK(t, os.MkdirAll(filepath.Dir(fp), 0755))
test.OK(t, os.MkdirAll(filepath.Dir(fp), 0755))
f, err := os.Create(fp)
OK(t, err)
test.OK(t, err)
fmt.Fprintf(f, filename)
OK(t, f.Close())
test.OK(t, f.Close())
}
snapshots := make(map[string]struct{})
@@ -555,23 +554,23 @@ func TestBackupExclude(t *testing.T) {
testRunBackup(t, []string{datadir}, opts, env.gopts)
snapshots, snapshotID := lastSnapshot(snapshots, loadSnapshotMap(t, env.gopts))
files := testRunLs(t, env.gopts, snapshotID)
Assert(t, includes(files, filepath.Join(string(filepath.Separator), "testdata", "foo.tar.gz")),
test.Assert(t, includes(files, filepath.Join(string(filepath.Separator), "testdata", "foo.tar.gz")),
"expected file %q in first snapshot, but it's not included", "foo.tar.gz")
opts.Excludes = []string{"*.tar.gz"}
testRunBackup(t, []string{datadir}, opts, env.gopts)
snapshots, snapshotID = lastSnapshot(snapshots, loadSnapshotMap(t, env.gopts))
files = testRunLs(t, env.gopts, snapshotID)
Assert(t, !includes(files, filepath.Join(string(filepath.Separator), "testdata", "foo.tar.gz")),
test.Assert(t, !includes(files, filepath.Join(string(filepath.Separator), "testdata", "foo.tar.gz")),
"expected file %q not in first snapshot, but it's included", "foo.tar.gz")
opts.Excludes = []string{"*.tar.gz", "private/secret"}
testRunBackup(t, []string{datadir}, opts, env.gopts)
_, snapshotID = lastSnapshot(snapshots, loadSnapshotMap(t, env.gopts))
files = testRunLs(t, env.gopts, snapshotID)
Assert(t, !includes(files, filepath.Join(string(filepath.Separator), "testdata", "foo.tar.gz")),
test.Assert(t, !includes(files, filepath.Join(string(filepath.Separator), "testdata", "foo.tar.gz")),
"expected file %q not in first snapshot, but it's included", "foo.tar.gz")
Assert(t, !includes(files, filepath.Join(string(filepath.Separator), "testdata", "private", "secret", "passwords.txt")),
test.Assert(t, !includes(files, filepath.Join(string(filepath.Separator), "testdata", "private", "secret", "passwords.txt")),
"expected file %q not in first snapshot, but it's included", "passwords.txt")
}
@@ -612,7 +611,7 @@ func TestIncrementalBackup(t *testing.T) {
datadir := filepath.Join(env.base, "testdata")
testfile := filepath.Join(datadir, "testfile")
OK(t, appendRandomData(testfile, incrementalFirstWrite))
test.OK(t, appendRandomData(testfile, incrementalFirstWrite))
opts := BackupOptions{}
@@ -620,7 +619,7 @@ func TestIncrementalBackup(t *testing.T) {
testRunCheck(t, env.gopts)
stat1 := dirStats(env.repo)
OK(t, appendRandomData(testfile, incrementalSecondWrite))
test.OK(t, appendRandomData(testfile, incrementalSecondWrite))
testRunBackup(t, []string{datadir}, opts, env.gopts)
testRunCheck(t, env.gopts)
@@ -630,7 +629,7 @@ func TestIncrementalBackup(t *testing.T) {
}
t.Logf("repository grown by %d bytes", stat2.size-stat1.size)
OK(t, appendRandomData(testfile, incrementalThirdWrite))
test.OK(t, appendRandomData(testfile, incrementalThirdWrite))
testRunBackup(t, []string{datadir}, opts, env.gopts)
testRunCheck(t, env.gopts)
@@ -647,28 +646,28 @@ func TestBackupTags(t *testing.T) {
datafile := filepath.Join("testdata", "backup-data.tar.gz")
testRunInit(t, env.gopts)
SetupTarTestFixture(t, env.testdata, datafile)
test.SetupTarTestFixture(t, env.testdata, datafile)
opts := BackupOptions{}
testRunBackup(t, []string{env.testdata}, opts, env.gopts)
testRunCheck(t, env.gopts)
newest, _ := testRunSnapshots(t, env.gopts)
Assert(t, newest != nil, "expected a new backup, got nil")
Assert(t, len(newest.Tags) == 0,
test.Assert(t, newest != nil, "expected a new backup, got nil")
test.Assert(t, len(newest.Tags) == 0,
"expected no tags, got %v", newest.Tags)
opts.Tags = []string{"NL"}
testRunBackup(t, []string{env.testdata}, opts, env.gopts)
testRunCheck(t, env.gopts)
newest, _ = testRunSnapshots(t, env.gopts)
Assert(t, newest != nil, "expected a new backup, got nil")
Assert(t, len(newest.Tags) == 1 && newest.Tags[0] == "NL",
test.Assert(t, newest != nil, "expected a new backup, got nil")
test.Assert(t, len(newest.Tags) == 1 && newest.Tags[0] == "NL",
"expected one NL tag, got %v", newest.Tags)
}
func testRunTag(t testing.TB, opts TagOptions, gopts GlobalOptions) {
OK(t, runTag(opts, gopts, []string{}))
test.OK(t, runTag(opts, gopts, []string{}))
}
func TestTag(t *testing.T) {
@@ -677,68 +676,68 @@ func TestTag(t *testing.T) {
datafile := filepath.Join("testdata", "backup-data.tar.gz")
testRunInit(t, env.gopts)
SetupTarTestFixture(t, env.testdata, datafile)
test.SetupTarTestFixture(t, env.testdata, datafile)
testRunBackup(t, []string{env.testdata}, BackupOptions{}, env.gopts)
testRunCheck(t, env.gopts)
newest, _ := testRunSnapshots(t, env.gopts)
Assert(t, newest != nil, "expected a new backup, got nil")
Assert(t, len(newest.Tags) == 0,
test.Assert(t, newest != nil, "expected a new backup, got nil")
test.Assert(t, len(newest.Tags) == 0,
"expected no tags, got %v", newest.Tags)
Assert(t, newest.Original == nil,
test.Assert(t, newest.Original == nil,
"expected original ID to be nil, got %v", newest.Original)
originalID := *newest.ID
testRunTag(t, TagOptions{SetTags: []string{"NL"}}, env.gopts)
testRunCheck(t, env.gopts)
newest, _ = testRunSnapshots(t, env.gopts)
Assert(t, newest != nil, "expected a new backup, got nil")
Assert(t, len(newest.Tags) == 1 && newest.Tags[0] == "NL",
test.Assert(t, newest != nil, "expected a new backup, got nil")
test.Assert(t, len(newest.Tags) == 1 && newest.Tags[0] == "NL",
"set failed, expected one NL tag, got %v", newest.Tags)
Assert(t, newest.Original != nil, "expected original snapshot id, got nil")
Assert(t, *newest.Original == originalID,
test.Assert(t, newest.Original != nil, "expected original snapshot id, got nil")
test.Assert(t, *newest.Original == originalID,
"expected original ID to be set to the first snapshot id")
testRunTag(t, TagOptions{AddTags: []string{"CH"}}, env.gopts)
testRunCheck(t, env.gopts)
newest, _ = testRunSnapshots(t, env.gopts)
Assert(t, newest != nil, "expected a new backup, got nil")
Assert(t, len(newest.Tags) == 2 && newest.Tags[0] == "NL" && newest.Tags[1] == "CH",
test.Assert(t, newest != nil, "expected a new backup, got nil")
test.Assert(t, len(newest.Tags) == 2 && newest.Tags[0] == "NL" && newest.Tags[1] == "CH",
"add failed, expected CH,NL tags, got %v", newest.Tags)
Assert(t, newest.Original != nil, "expected original snapshot id, got nil")
Assert(t, *newest.Original == originalID,
test.Assert(t, newest.Original != nil, "expected original snapshot id, got nil")
test.Assert(t, *newest.Original == originalID,
"expected original ID to be set to the first snapshot id")
testRunTag(t, TagOptions{RemoveTags: []string{"NL"}}, env.gopts)
testRunCheck(t, env.gopts)
newest, _ = testRunSnapshots(t, env.gopts)
Assert(t, newest != nil, "expected a new backup, got nil")
Assert(t, len(newest.Tags) == 1 && newest.Tags[0] == "CH",
test.Assert(t, newest != nil, "expected a new backup, got nil")
test.Assert(t, len(newest.Tags) == 1 && newest.Tags[0] == "CH",
"remove failed, expected one CH tag, got %v", newest.Tags)
Assert(t, newest.Original != nil, "expected original snapshot id, got nil")
Assert(t, *newest.Original == originalID,
test.Assert(t, newest.Original != nil, "expected original snapshot id, got nil")
test.Assert(t, *newest.Original == originalID,
"expected original ID to be set to the first snapshot id")
testRunTag(t, TagOptions{AddTags: []string{"US", "RU"}}, env.gopts)
testRunTag(t, TagOptions{RemoveTags: []string{"CH", "US", "RU"}}, env.gopts)
testRunCheck(t, env.gopts)
newest, _ = testRunSnapshots(t, env.gopts)
Assert(t, newest != nil, "expected a new backup, got nil")
Assert(t, len(newest.Tags) == 0,
test.Assert(t, newest != nil, "expected a new backup, got nil")
test.Assert(t, len(newest.Tags) == 0,
"expected no tags, got %v", newest.Tags)
Assert(t, newest.Original != nil, "expected original snapshot id, got nil")
Assert(t, *newest.Original == originalID,
test.Assert(t, newest.Original != nil, "expected original snapshot id, got nil")
test.Assert(t, *newest.Original == originalID,
"expected original ID to be set to the first snapshot id")
// Check special case of removing all tags.
testRunTag(t, TagOptions{SetTags: []string{""}}, env.gopts)
testRunCheck(t, env.gopts)
newest, _ = testRunSnapshots(t, env.gopts)
Assert(t, newest != nil, "expected a new backup, got nil")
Assert(t, len(newest.Tags) == 0,
test.Assert(t, newest != nil, "expected a new backup, got nil")
test.Assert(t, len(newest.Tags) == 0,
"expected no tags, got %v", newest.Tags)
Assert(t, newest.Original != nil, "expected original snapshot id, got nil")
Assert(t, *newest.Original == originalID,
test.Assert(t, newest.Original != nil, "expected original snapshot id, got nil")
test.Assert(t, *newest.Original == originalID,
"expected original ID to be set to the first snapshot id")
}
@@ -750,7 +749,7 @@ func testRunKeyListOtherIDs(t testing.TB, gopts GlobalOptions) []string {
globalOptions.stdout = os.Stdout
}()
OK(t, runKey(gopts, []string{"list"}))
test.OK(t, runKey(gopts, []string{"list"}))
scanner := bufio.NewScanner(buf)
exp := regexp.MustCompile(`^ ([a-f0-9]+) `)
@@ -771,7 +770,7 @@ func testRunKeyAddNewKey(t testing.TB, newPassword string, gopts GlobalOptions)
testKeyNewPassword = ""
}()
OK(t, runKey(gopts, []string{"add"}))
test.OK(t, runKey(gopts, []string{"add"}))
}
func testRunKeyPasswd(t testing.TB, newPassword string, gopts GlobalOptions) {
@@ -780,13 +779,13 @@ func testRunKeyPasswd(t testing.TB, newPassword string, gopts GlobalOptions) {
testKeyNewPassword = ""
}()
OK(t, runKey(gopts, []string{"passwd"}))
test.OK(t, runKey(gopts, []string{"passwd"}))
}
func testRunKeyRemove(t testing.TB, gopts GlobalOptions, IDs []string) {
t.Logf("remove %d keys: %q\n", len(IDs), IDs)
for _, id := range IDs {
OK(t, runKey(gopts, []string{"remove", id}))
test.OK(t, runKey(gopts, []string{"remove", id}))
}
}
@@ -814,7 +813,7 @@ func TestKeyAddRemove(t *testing.T) {
env.gopts.password = passwordList[len(passwordList)-1]
t.Logf("testing access with last password %q\n", env.gopts.password)
OK(t, runKey(env.gopts, []string{"list"}))
test.OK(t, runKey(env.gopts, []string{"list"}))
testRunCheck(t, env.gopts)
}
@@ -847,10 +846,10 @@ func TestRestoreFilter(t *testing.T) {
testRunInit(t, env.gopts)
for _, test := range testfiles {
p := filepath.Join(env.testdata, test.name)
OK(t, os.MkdirAll(filepath.Dir(p), 0755))
OK(t, appendRandomData(p, test.size))
for _, testFile := range testfiles {
p := filepath.Join(env.testdata, testFile.name)
test.OK(t, os.MkdirAll(filepath.Dir(p), 0755))
test.OK(t, appendRandomData(p, testFile.size))
}
opts := BackupOptions{}
@@ -862,20 +861,20 @@ func TestRestoreFilter(t *testing.T) {
// no restore filter should restore all files
testRunRestore(t, env.gopts, filepath.Join(env.base, "restore0"), snapshotID)
for _, test := range testfiles {
OK(t, testFileSize(filepath.Join(env.base, "restore0", "testdata", test.name), int64(test.size)))
for _, testFile := range testfiles {
test.OK(t, testFileSize(filepath.Join(env.base, "restore0", "testdata", testFile.name), int64(testFile.size)))
}
for i, pat := range []string{"*.c", "*.exe", "*", "*file3*"} {
base := filepath.Join(env.base, fmt.Sprintf("restore%d", i+1))
testRunRestoreExcludes(t, env.gopts, base, snapshotID, []string{pat})
for _, test := range testfiles {
err := testFileSize(filepath.Join(base, "testdata", test.name), int64(test.size))
if ok, _ := filter.Match(pat, filepath.Base(test.name)); !ok {
OK(t, err)
for _, testFile := range testfiles {
err := testFileSize(filepath.Join(base, "testdata", testFile.name), int64(testFile.size))
if ok, _ := filter.Match(pat, filepath.Base(testFile.name)); !ok {
test.OK(t, err)
} else {
Assert(t, os.IsNotExist(errors.Cause(err)),
"expected %v to not exist in restore step %v, but it exists, err %v", test.name, i+1, err)
test.Assert(t, os.IsNotExist(errors.Cause(err)),
"expected %v to not exist in restore step %v, but it exists, err %v", testFile.name, i+1, err)
}
}
}
@@ -889,8 +888,8 @@ func TestRestore(t *testing.T) {
for i := 0; i < 10; i++ {
p := filepath.Join(env.testdata, fmt.Sprintf("foo/bar/testfile%v", i))
OK(t, os.MkdirAll(filepath.Dir(p), 0755))
OK(t, appendRandomData(p, uint(mrand.Intn(5<<21))))
test.OK(t, os.MkdirAll(filepath.Dir(p), 0755))
test.OK(t, appendRandomData(p, uint(mrand.Intn(5<<21))))
}
opts := BackupOptions{}
@@ -902,7 +901,7 @@ func TestRestore(t *testing.T) {
restoredir := filepath.Join(env.base, "restore")
testRunRestoreLatest(t, env.gopts, restoredir, nil, "")
Assert(t, directoriesEqualContents(env.testdata, filepath.Join(restoredir, filepath.Base(env.testdata))),
test.Assert(t, directoriesEqualContents(env.testdata, filepath.Join(restoredir, filepath.Base(env.testdata))),
"directories are not equal")
}
@@ -913,8 +912,8 @@ func TestRestoreLatest(t *testing.T) {
testRunInit(t, env.gopts)
p := filepath.Join(env.testdata, "testfile.c")
OK(t, os.MkdirAll(filepath.Dir(p), 0755))
OK(t, appendRandomData(p, 100))
test.OK(t, os.MkdirAll(filepath.Dir(p), 0755))
test.OK(t, appendRandomData(p, 100))
opts := BackupOptions{}
@@ -922,24 +921,24 @@ func TestRestoreLatest(t *testing.T) {
testRunCheck(t, env.gopts)
os.Remove(p)
OK(t, appendRandomData(p, 101))
test.OK(t, appendRandomData(p, 101))
testRunBackup(t, []string{env.testdata}, opts, env.gopts)
testRunCheck(t, env.gopts)
// Restore latest without any filters
testRunRestoreLatest(t, env.gopts, filepath.Join(env.base, "restore0"), nil, "")
OK(t, testFileSize(filepath.Join(env.base, "restore0", "testdata", "testfile.c"), int64(101)))
test.OK(t, testFileSize(filepath.Join(env.base, "restore0", "testdata", "testfile.c"), int64(101)))
// Setup test files in different directories backed up in different snapshots
p1 := filepath.Join(env.testdata, "p1/testfile.c")
OK(t, os.MkdirAll(filepath.Dir(p1), 0755))
OK(t, appendRandomData(p1, 102))
test.OK(t, os.MkdirAll(filepath.Dir(p1), 0755))
test.OK(t, appendRandomData(p1, 102))
testRunBackup(t, []string{filepath.Dir(p1)}, opts, env.gopts)
testRunCheck(t, env.gopts)
p2 := filepath.Join(env.testdata, "p2/testfile.c")
OK(t, os.MkdirAll(filepath.Dir(p2), 0755))
OK(t, appendRandomData(p2, 103))
test.OK(t, os.MkdirAll(filepath.Dir(p2), 0755))
test.OK(t, appendRandomData(p2, 103))
testRunBackup(t, []string{filepath.Dir(p2)}, opts, env.gopts)
testRunCheck(t, env.gopts)
@@ -947,16 +946,16 @@ func TestRestoreLatest(t *testing.T) {
p2rAbs := filepath.Join(env.base, "restore2", "p2/testfile.c")
testRunRestoreLatest(t, env.gopts, filepath.Join(env.base, "restore1"), []string{filepath.Dir(p1)}, "")
OK(t, testFileSize(p1rAbs, int64(102)))
test.OK(t, testFileSize(p1rAbs, int64(102)))
if _, err := os.Stat(p2rAbs); os.IsNotExist(errors.Cause(err)) {
Assert(t, os.IsNotExist(errors.Cause(err)),
test.Assert(t, os.IsNotExist(errors.Cause(err)),
"expected %v to not exist in restore, but it exists, err %v", p2rAbs, err)
}
testRunRestoreLatest(t, env.gopts, filepath.Join(env.base, "restore2"), []string{filepath.Dir(p2)}, "")
OK(t, testFileSize(p2rAbs, int64(103)))
test.OK(t, testFileSize(p2rAbs, int64(103)))
if _, err := os.Stat(p1rAbs); os.IsNotExist(errors.Cause(err)) {
Assert(t, os.IsNotExist(errors.Cause(err)),
test.Assert(t, os.IsNotExist(errors.Cause(err)),
"expected %v to not exist in restore, but it exists, err %v", p1rAbs, err)
}
}
@@ -966,10 +965,10 @@ func TestRestoreWithPermissionFailure(t *testing.T) {
defer cleanup()
datafile := filepath.Join("testdata", "repo-restore-permissions-test.tar.gz")
SetupTarTestFixture(t, env.base, datafile)
test.SetupTarTestFixture(t, env.base, datafile)
snapshots := testRunList(t, "snapshots", env.gopts)
Assert(t, len(snapshots) > 0,
test.Assert(t, len(snapshots) > 0,
"no snapshots found in repo (%v)", datafile)
globalOptions.stderr = ioutil.Discard
@@ -984,9 +983,9 @@ func TestRestoreWithPermissionFailure(t *testing.T) {
files := testRunLs(t, env.gopts, snapshots[0].String())
for _, filename := range files {
fi, err := os.Lstat(filepath.Join(env.base, "restore", filename))
OK(t, err)
test.OK(t, err)
Assert(t, !isFile(fi) || fi.Size() > 0,
test.Assert(t, !isFile(fi) || fi.Size() > 0,
"file %v restored, but filesize is 0", filename)
}
}
@@ -1007,9 +1006,9 @@ func TestRestoreNoMetadataOnIgnoredIntermediateDirs(t *testing.T) {
testRunInit(t, env.gopts)
p := filepath.Join(env.testdata, "subdir1", "subdir2", "subdir3", "file.ext")
OK(t, os.MkdirAll(filepath.Dir(p), 0755))
OK(t, appendRandomData(p, 200))
OK(t, setZeroModTime(filepath.Join(env.testdata, "subdir1", "subdir2")))
test.OK(t, os.MkdirAll(filepath.Dir(p), 0755))
test.OK(t, appendRandomData(p, 200))
test.OK(t, setZeroModTime(filepath.Join(env.testdata, "subdir1", "subdir2")))
opts := BackupOptions{}
@@ -1025,9 +1024,9 @@ func TestRestoreNoMetadataOnIgnoredIntermediateDirs(t *testing.T) {
f1 := filepath.Join(env.base, "restore0", "testdata", "subdir1", "subdir2")
fi, err := os.Stat(f1)
OK(t, err)
test.OK(t, err)
Assert(t, fi.ModTime() != time.Unix(0, 0),
test.Assert(t, fi.ModTime() != time.Unix(0, 0),
"meta data of intermediate directory has been restore although it was ignored")
// restore with filter "*", this should restore meta data on everything.
@@ -1035,9 +1034,9 @@ func TestRestoreNoMetadataOnIgnoredIntermediateDirs(t *testing.T) {
f2 := filepath.Join(env.base, "restore1", "testdata", "subdir1", "subdir2")
fi, err = os.Stat(f2)
OK(t, err)
test.OK(t, err)
Assert(t, fi.ModTime() == time.Unix(0, 0),
test.Assert(t, fi.ModTime() == time.Unix(0, 0),
"meta data of intermediate directory hasn't been restore")
}
@@ -1047,7 +1046,7 @@ func TestFind(t *testing.T) {
datafile := filepath.Join("testdata", "backup-data.tar.gz")
testRunInit(t, env.gopts)
SetupTarTestFixture(t, env.testdata, datafile)
test.SetupTarTestFixture(t, env.testdata, datafile)
opts := BackupOptions{}
@@ -1055,15 +1054,15 @@ func TestFind(t *testing.T) {
testRunCheck(t, env.gopts)
results := testRunFind(t, false, env.gopts, "unexistingfile")
Assert(t, len(results) == 0, "unexisting file found in repo (%v)", datafile)
test.Assert(t, len(results) == 0, "unexisting file found in repo (%v)", datafile)
results = testRunFind(t, false, env.gopts, "testfile")
lines := strings.Split(string(results), "\n")
Assert(t, len(lines) == 2, "expected one file found in repo (%v)", datafile)
test.Assert(t, len(lines) == 2, "expected one file found in repo (%v)", datafile)
results = testRunFind(t, false, env.gopts, "testfile*")
lines = strings.Split(string(results), "\n")
Assert(t, len(lines) == 4, "expected three files found in repo (%v)", datafile)
test.Assert(t, len(lines) == 4, "expected three files found in repo (%v)", datafile)
}
type testMatch struct {
@@ -1087,7 +1086,7 @@ func TestFindJSON(t *testing.T) {
datafile := filepath.Join("testdata", "backup-data.tar.gz")
testRunInit(t, env.gopts)
SetupTarTestFixture(t, env.testdata, datafile)
test.SetupTarTestFixture(t, env.testdata, datafile)
opts := BackupOptions{}
@@ -1096,20 +1095,20 @@ func TestFindJSON(t *testing.T) {
results := testRunFind(t, true, env.gopts, "unexistingfile")
matches := []testMatches{}
OK(t, json.Unmarshal(results, &matches))
Assert(t, len(matches) == 0, "expected no match in repo (%v)", datafile)
test.OK(t, json.Unmarshal(results, &matches))
test.Assert(t, len(matches) == 0, "expected no match in repo (%v)", datafile)
results = testRunFind(t, true, env.gopts, "testfile")
OK(t, json.Unmarshal(results, &matches))
Assert(t, len(matches) == 1, "expected a single snapshot in repo (%v)", datafile)
Assert(t, len(matches[0].Matches) == 1, "expected a single file to match (%v)", datafile)
Assert(t, matches[0].Hits == 1, "expected hits to show 1 match (%v)", datafile)
test.OK(t, json.Unmarshal(results, &matches))
test.Assert(t, len(matches) == 1, "expected a single snapshot in repo (%v)", datafile)
test.Assert(t, len(matches[0].Matches) == 1, "expected a single file to match (%v)", datafile)
test.Assert(t, matches[0].Hits == 1, "expected hits to show 1 match (%v)", datafile)
results = testRunFind(t, true, env.gopts, "testfile*")
OK(t, json.Unmarshal(results, &matches))
Assert(t, len(matches) == 1, "expected a single snapshot in repo (%v)", datafile)
Assert(t, len(matches[0].Matches) == 3, "expected 3 files to match (%v)", datafile)
Assert(t, matches[0].Hits == 3, "expected hits to show 3 matches (%v)", datafile)
test.OK(t, json.Unmarshal(results, &matches))
test.Assert(t, len(matches) == 1, "expected a single snapshot in repo (%v)", datafile)
test.Assert(t, len(matches[0].Matches) == 3, "expected 3 files to match (%v)", datafile)
test.Assert(t, matches[0].Hits == 3, "expected hits to show 3 matches (%v)", datafile)
}
func TestRebuildIndex(t *testing.T) {
@@ -1117,7 +1116,7 @@ func TestRebuildIndex(t *testing.T) {
defer cleanup()
datafile := filepath.Join("..", "..", "internal", "checker", "testdata", "duplicate-packs-in-index-test-repo.tar.gz")
SetupTarTestFixture(t, env.base, datafile)
test.SetupTarTestFixture(t, env.base, datafile)
out, err := testRunCheckOutput(env.gopts)
if !strings.Contains(out, "contained in several indexes") {
@@ -1154,7 +1153,7 @@ func TestCheckRestoreNoLock(t *testing.T) {
defer cleanup()
datafile := filepath.Join("testdata", "small-repo.tar.gz")
SetupTarTestFixture(t, env.base, datafile)
test.SetupTarTestFixture(t, env.base, datafile)
err := filepath.Walk(env.repo, func(p string, fi os.FileInfo, e error) error {
if e != nil {
@@ -1162,7 +1161,7 @@ func TestCheckRestoreNoLock(t *testing.T) {
}
return os.Chmod(p, fi.Mode() & ^(os.FileMode(0222)))
})
OK(t, err)
test.OK(t, err)
env.gopts.NoLock = true
@@ -1186,24 +1185,24 @@ func TestPrune(t *testing.T) {
t.Skipf("unable to find data file %q, skipping", datafile)
return
}
OK(t, err)
OK(t, fd.Close())
test.OK(t, err)
test.OK(t, fd.Close())
testRunInit(t, env.gopts)
SetupTarTestFixture(t, env.testdata, datafile)
test.SetupTarTestFixture(t, env.testdata, datafile)
opts := BackupOptions{}
testRunBackup(t, []string{filepath.Join(env.testdata, "0", "0")}, opts, env.gopts)
firstSnapshot := testRunList(t, "snapshots", env.gopts)
Assert(t, len(firstSnapshot) == 1,
test.Assert(t, len(firstSnapshot) == 1,
"expected one snapshot, got %v", firstSnapshot)
testRunBackup(t, []string{filepath.Join(env.testdata, "0", "0", "2")}, opts, env.gopts)
testRunBackup(t, []string{filepath.Join(env.testdata, "0", "0", "3")}, opts, env.gopts)
snapshotIDs := testRunList(t, "snapshots", env.gopts)
Assert(t, len(snapshotIDs) == 3,
test.Assert(t, len(snapshotIDs) == 3,
"expected 3 snapshot, got %v", snapshotIDs)
testRunForget(t, env.gopts, firstSnapshot[0].String())
@@ -1222,12 +1221,12 @@ func TestHardLink(t *testing.T) {
t.Skipf("unable to find data file %q, skipping", datafile)
return
}
OK(t, err)
OK(t, fd.Close())
test.OK(t, err)
test.OK(t, fd.Close())
testRunInit(t, env.gopts)
SetupTarTestFixture(t, env.testdata, datafile)
test.SetupTarTestFixture(t, env.testdata, datafile)
linkTests := createFileSetPerHardlink(env.testdata)
@@ -1236,7 +1235,7 @@ func TestHardLink(t *testing.T) {
// first backup
testRunBackup(t, []string{env.testdata}, opts, env.gopts)
snapshotIDs := testRunList(t, "snapshots", env.gopts)
Assert(t, len(snapshotIDs) == 1,
test.Assert(t, len(snapshotIDs) == 1,
"expected one snapshot, got %v", snapshotIDs)
testRunCheck(t, env.gopts)
@@ -1246,11 +1245,11 @@ func TestHardLink(t *testing.T) {
restoredir := filepath.Join(env.base, fmt.Sprintf("restore%d", i))
t.Logf("restoring snapshot %v to %v", snapshotID.Str(), restoredir)
testRunRestore(t, env.gopts, restoredir, snapshotIDs[0])
Assert(t, directoriesEqualContents(env.testdata, filepath.Join(restoredir, "testdata")),
test.Assert(t, directoriesEqualContents(env.testdata, filepath.Join(restoredir, "testdata")),
"directories are not equal")
linkResults := createFileSetPerHardlink(filepath.Join(restoredir, "testdata"))
Assert(t, linksEqual(linkTests, linkResults),
test.Assert(t, linksEqual(linkTests, linkResults),
"links are not equal")
}

View File

@@ -4,7 +4,7 @@ import (
"path/filepath"
"testing"
. "github.com/restic/restic/internal/test"
rtest "github.com/restic/restic/internal/test"
)
func TestRestoreLocalLayout(t *testing.T) {
@@ -24,7 +24,7 @@ func TestRestoreLocalLayout(t *testing.T) {
for _, test := range tests {
datafile := filepath.Join("..", "..", "internal", "backend", "testdata", test.filename)
SetupTarTestFixture(t, env.base, datafile)
rtest.SetupTarTestFixture(t, env.base, datafile)
env.gopts.extended["local.layout"] = test.layout
@@ -35,7 +35,7 @@ func TestRestoreLocalLayout(t *testing.T) {
target := filepath.Join(env.base, "restore")
testRunRestoreLatest(t, env.gopts, target, nil, "")
RemoveAll(t, filepath.Join(env.base, "repo"))
RemoveAll(t, target)
rtest.RemoveAll(t, filepath.Join(env.base, "repo"))
rtest.RemoveAll(t, target)
}
}