mirror of
https://github.com/restic/restic.git
synced 2025-12-13 12:42:37 +00:00
list: cleanup parameter order of test helper
This commit is contained in:
@@ -218,41 +218,41 @@ func TestDryRunBackup(t *testing.T) {
|
|||||||
// dry run before first backup
|
// dry run before first backup
|
||||||
testRunBackup(t, filepath.Dir(env.testdata), []string{"testdata"}, dryOpts, env.gopts)
|
testRunBackup(t, filepath.Dir(env.testdata), []string{"testdata"}, dryOpts, env.gopts)
|
||||||
snapshotIDs := testListSnapshots(t, env.gopts, 0)
|
snapshotIDs := testListSnapshots(t, env.gopts, 0)
|
||||||
packIDs := testRunList(t, "packs", env.gopts)
|
packIDs := testRunList(t, env.gopts, "packs")
|
||||||
rtest.Assert(t, len(packIDs) == 0,
|
rtest.Assert(t, len(packIDs) == 0,
|
||||||
"expected no data, got %v", snapshotIDs)
|
"expected no data, got %v", snapshotIDs)
|
||||||
indexIDs := testRunList(t, "index", env.gopts)
|
indexIDs := testRunList(t, env.gopts, "index")
|
||||||
rtest.Assert(t, len(indexIDs) == 0,
|
rtest.Assert(t, len(indexIDs) == 0,
|
||||||
"expected no index, got %v", snapshotIDs)
|
"expected no index, got %v", snapshotIDs)
|
||||||
|
|
||||||
// first backup
|
// first backup
|
||||||
testRunBackup(t, filepath.Dir(env.testdata), []string{"testdata"}, opts, env.gopts)
|
testRunBackup(t, filepath.Dir(env.testdata), []string{"testdata"}, opts, env.gopts)
|
||||||
snapshotIDs = testListSnapshots(t, env.gopts, 1)
|
snapshotIDs = testListSnapshots(t, env.gopts, 1)
|
||||||
packIDs = testRunList(t, "packs", env.gopts)
|
packIDs = testRunList(t, env.gopts, "packs")
|
||||||
indexIDs = testRunList(t, "index", env.gopts)
|
indexIDs = testRunList(t, env.gopts, "index")
|
||||||
|
|
||||||
// dry run between backups
|
// dry run between backups
|
||||||
testRunBackup(t, filepath.Dir(env.testdata), []string{"testdata"}, dryOpts, env.gopts)
|
testRunBackup(t, filepath.Dir(env.testdata), []string{"testdata"}, dryOpts, env.gopts)
|
||||||
snapshotIDsAfter := testListSnapshots(t, env.gopts, 1)
|
snapshotIDsAfter := testListSnapshots(t, env.gopts, 1)
|
||||||
rtest.Equals(t, snapshotIDs, snapshotIDsAfter)
|
rtest.Equals(t, snapshotIDs, snapshotIDsAfter)
|
||||||
dataIDsAfter := testRunList(t, "packs", env.gopts)
|
dataIDsAfter := testRunList(t, env.gopts, "packs")
|
||||||
rtest.Equals(t, packIDs, dataIDsAfter)
|
rtest.Equals(t, packIDs, dataIDsAfter)
|
||||||
indexIDsAfter := testRunList(t, "index", env.gopts)
|
indexIDsAfter := testRunList(t, env.gopts, "index")
|
||||||
rtest.Equals(t, indexIDs, indexIDsAfter)
|
rtest.Equals(t, indexIDs, indexIDsAfter)
|
||||||
|
|
||||||
// second backup, implicit incremental
|
// second backup, implicit incremental
|
||||||
testRunBackup(t, filepath.Dir(env.testdata), []string{"testdata"}, opts, env.gopts)
|
testRunBackup(t, filepath.Dir(env.testdata), []string{"testdata"}, opts, env.gopts)
|
||||||
snapshotIDs = testListSnapshots(t, env.gopts, 2)
|
snapshotIDs = testListSnapshots(t, env.gopts, 2)
|
||||||
packIDs = testRunList(t, "packs", env.gopts)
|
packIDs = testRunList(t, env.gopts, "packs")
|
||||||
indexIDs = testRunList(t, "index", env.gopts)
|
indexIDs = testRunList(t, env.gopts, "index")
|
||||||
|
|
||||||
// another dry run
|
// another dry run
|
||||||
testRunBackup(t, filepath.Dir(env.testdata), []string{"testdata"}, dryOpts, env.gopts)
|
testRunBackup(t, filepath.Dir(env.testdata), []string{"testdata"}, dryOpts, env.gopts)
|
||||||
snapshotIDsAfter = testListSnapshots(t, env.gopts, 2)
|
snapshotIDsAfter = testListSnapshots(t, env.gopts, 2)
|
||||||
rtest.Equals(t, snapshotIDs, snapshotIDsAfter)
|
rtest.Equals(t, snapshotIDs, snapshotIDsAfter)
|
||||||
dataIDsAfter = testRunList(t, "packs", env.gopts)
|
dataIDsAfter = testRunList(t, env.gopts, "packs")
|
||||||
rtest.Equals(t, packIDs, dataIDsAfter)
|
rtest.Equals(t, packIDs, dataIDsAfter)
|
||||||
indexIDsAfter = testRunList(t, "index", env.gopts)
|
indexIDsAfter = testRunList(t, env.gopts, "index")
|
||||||
rtest.Equals(t, indexIDs, indexIDsAfter)
|
rtest.Equals(t, indexIDs, indexIDsAfter)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -10,9 +10,9 @@ import (
|
|||||||
rtest "github.com/restic/restic/internal/test"
|
rtest "github.com/restic/restic/internal/test"
|
||||||
)
|
)
|
||||||
|
|
||||||
func testRunList(t testing.TB, tpe string, opts GlobalOptions) restic.IDs {
|
func testRunList(t testing.TB, gopts GlobalOptions, tpe string) restic.IDs {
|
||||||
buf, err := withCaptureStdout(func() error {
|
buf, err := withCaptureStdout(func() error {
|
||||||
return runList(context.TODO(), opts, []string{tpe})
|
return runList(context.TODO(), gopts, []string{tpe})
|
||||||
})
|
})
|
||||||
rtest.OK(t, err)
|
rtest.OK(t, err)
|
||||||
return parseIDsFromReader(t, buf)
|
return parseIDsFromReader(t, buf)
|
||||||
@@ -38,7 +38,7 @@ func parseIDsFromReader(t testing.TB, rd io.Reader) restic.IDs {
|
|||||||
|
|
||||||
func testListSnapshots(t testing.TB, opts GlobalOptions, expected int) restic.IDs {
|
func testListSnapshots(t testing.TB, opts GlobalOptions, expected int) restic.IDs {
|
||||||
t.Helper()
|
t.Helper()
|
||||||
snapshotIDs := testRunList(t, "snapshots", opts)
|
snapshotIDs := testRunList(t, opts, "snapshots")
|
||||||
rtest.Assert(t, len(snapshotIDs) == expected, "expected %v snapshot, got %v", expected, snapshotIDs)
|
rtest.Assert(t, len(snapshotIDs) == expected, "expected %v snapshot, got %v", expected, snapshotIDs)
|
||||||
return snapshotIDs
|
return snapshotIDs
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -177,7 +177,7 @@ func TestMount(t *testing.T) {
|
|||||||
|
|
||||||
// first backup
|
// first backup
|
||||||
testRunBackup(t, "", []string{env.testdata}, BackupOptions{}, env.gopts)
|
testRunBackup(t, "", []string{env.testdata}, BackupOptions{}, env.gopts)
|
||||||
snapshotIDs := testRunList(t, "snapshots", env.gopts)
|
snapshotIDs := testRunList(t, env.gopts, "snapshots")
|
||||||
rtest.Assert(t, len(snapshotIDs) == 1,
|
rtest.Assert(t, len(snapshotIDs) == 1,
|
||||||
"expected one snapshot, got %v", snapshotIDs)
|
"expected one snapshot, got %v", snapshotIDs)
|
||||||
|
|
||||||
@@ -185,7 +185,7 @@ func TestMount(t *testing.T) {
|
|||||||
|
|
||||||
// second backup, implicit incremental
|
// second backup, implicit incremental
|
||||||
testRunBackup(t, "", []string{env.testdata}, BackupOptions{}, env.gopts)
|
testRunBackup(t, "", []string{env.testdata}, BackupOptions{}, env.gopts)
|
||||||
snapshotIDs = testRunList(t, "snapshots", env.gopts)
|
snapshotIDs = testRunList(t, env.gopts, "snapshots")
|
||||||
rtest.Assert(t, len(snapshotIDs) == 2,
|
rtest.Assert(t, len(snapshotIDs) == 2,
|
||||||
"expected two snapshots, got %v", snapshotIDs)
|
"expected two snapshots, got %v", snapshotIDs)
|
||||||
|
|
||||||
@@ -194,7 +194,7 @@ func TestMount(t *testing.T) {
|
|||||||
// third backup, explicit incremental
|
// third backup, explicit incremental
|
||||||
bopts := BackupOptions{Parent: snapshotIDs[0].String()}
|
bopts := BackupOptions{Parent: snapshotIDs[0].String()}
|
||||||
testRunBackup(t, "", []string{env.testdata}, bopts, env.gopts)
|
testRunBackup(t, "", []string{env.testdata}, bopts, env.gopts)
|
||||||
snapshotIDs = testRunList(t, "snapshots", env.gopts)
|
snapshotIDs = testRunList(t, env.gopts, "snapshots")
|
||||||
rtest.Assert(t, len(snapshotIDs) == 3,
|
rtest.Assert(t, len(snapshotIDs) == 3,
|
||||||
"expected three snapshots, got %v", snapshotIDs)
|
"expected three snapshots, got %v", snapshotIDs)
|
||||||
|
|
||||||
|
|||||||
@@ -77,7 +77,7 @@ func TestRepairSnapshotsWithLostTree(t *testing.T) {
|
|||||||
createRandomFile(t, env, "foo/bar/file", 12345)
|
createRandomFile(t, env, "foo/bar/file", 12345)
|
||||||
testRunBackup(t, "", []string{env.testdata}, BackupOptions{}, env.gopts)
|
testRunBackup(t, "", []string{env.testdata}, BackupOptions{}, env.gopts)
|
||||||
oldSnapshot := testListSnapshots(t, env.gopts, 1)
|
oldSnapshot := testListSnapshots(t, env.gopts, 1)
|
||||||
oldPacks := testRunList(t, "packs", env.gopts)
|
oldPacks := testRunList(t, env.gopts, "packs")
|
||||||
|
|
||||||
// keep foo/bar unchanged
|
// keep foo/bar unchanged
|
||||||
createRandomFile(t, env, "foo/bar2", 1024)
|
createRandomFile(t, env, "foo/bar2", 1024)
|
||||||
@@ -106,7 +106,7 @@ func TestRepairSnapshotsWithLostRootTree(t *testing.T) {
|
|||||||
createRandomFile(t, env, "foo/bar/file", 12345)
|
createRandomFile(t, env, "foo/bar/file", 12345)
|
||||||
testRunBackup(t, "", []string{env.testdata}, BackupOptions{}, env.gopts)
|
testRunBackup(t, "", []string{env.testdata}, BackupOptions{}, env.gopts)
|
||||||
testListSnapshots(t, env.gopts, 1)
|
testListSnapshots(t, env.gopts, 1)
|
||||||
oldPacks := testRunList(t, "packs", env.gopts)
|
oldPacks := testRunList(t, env.gopts, "packs")
|
||||||
|
|
||||||
// remove all trees
|
// remove all trees
|
||||||
removePacks(env.gopts, t, restic.NewIDSet(oldPacks...))
|
removePacks(env.gopts, t, restic.NewIDSet(oldPacks...))
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ func createBasicRewriteRepo(t testing.TB, env *testEnvironment) restic.ID {
|
|||||||
|
|
||||||
// create backup
|
// create backup
|
||||||
testRunBackup(t, filepath.Dir(env.testdata), []string{"testdata"}, BackupOptions{}, env.gopts)
|
testRunBackup(t, filepath.Dir(env.testdata), []string{"testdata"}, BackupOptions{}, env.gopts)
|
||||||
snapshotIDs := testRunList(t, "snapshots", env.gopts)
|
snapshotIDs := testRunList(t, env.gopts, "snapshots")
|
||||||
rtest.Assert(t, len(snapshotIDs) == 1, "expected one snapshot, got %v", snapshotIDs)
|
rtest.Assert(t, len(snapshotIDs) == 1, "expected one snapshot, got %v", snapshotIDs)
|
||||||
testRunCheck(t, env.gopts)
|
testRunCheck(t, env.gopts)
|
||||||
|
|
||||||
@@ -60,7 +60,7 @@ func TestRewrite(t *testing.T) {
|
|||||||
|
|
||||||
// exclude some data
|
// exclude some data
|
||||||
testRunRewriteExclude(t, env.gopts, []string{"3"}, false, snapshotMetadataArgs{Hostname: "", Time: ""})
|
testRunRewriteExclude(t, env.gopts, []string{"3"}, false, snapshotMetadataArgs{Hostname: "", Time: ""})
|
||||||
snapshotIDs := testRunList(t, "snapshots", env.gopts)
|
snapshotIDs := testRunList(t, env.gopts, "snapshots")
|
||||||
rtest.Assert(t, len(snapshotIDs) == 2, "expected two snapshots, got %v", snapshotIDs)
|
rtest.Assert(t, len(snapshotIDs) == 2, "expected two snapshots, got %v", snapshotIDs)
|
||||||
testRunCheck(t, env.gopts)
|
testRunCheck(t, env.gopts)
|
||||||
}
|
}
|
||||||
@@ -72,7 +72,7 @@ func TestRewriteUnchanged(t *testing.T) {
|
|||||||
|
|
||||||
// use an exclude that will not exclude anything
|
// use an exclude that will not exclude anything
|
||||||
testRunRewriteExclude(t, env.gopts, []string{"3dflkhjgdflhkjetrlkhjgfdlhkj"}, false, snapshotMetadataArgs{Hostname: "", Time: ""})
|
testRunRewriteExclude(t, env.gopts, []string{"3dflkhjgdflhkjetrlkhjgfdlhkj"}, false, snapshotMetadataArgs{Hostname: "", Time: ""})
|
||||||
newSnapshotIDs := testRunList(t, "snapshots", env.gopts)
|
newSnapshotIDs := testRunList(t, env.gopts, "snapshots")
|
||||||
rtest.Assert(t, len(newSnapshotIDs) == 1, "expected one snapshot, got %v", newSnapshotIDs)
|
rtest.Assert(t, len(newSnapshotIDs) == 1, "expected one snapshot, got %v", newSnapshotIDs)
|
||||||
rtest.Assert(t, snapshotID == newSnapshotIDs[0], "snapshot id changed unexpectedly")
|
rtest.Assert(t, snapshotID == newSnapshotIDs[0], "snapshot id changed unexpectedly")
|
||||||
testRunCheck(t, env.gopts)
|
testRunCheck(t, env.gopts)
|
||||||
|
|||||||
@@ -333,7 +333,7 @@ func includes(haystack []string, needle string) bool {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func loadSnapshotMap(t testing.TB, gopts GlobalOptions) map[string]struct{} {
|
func loadSnapshotMap(t testing.TB, gopts GlobalOptions) map[string]struct{} {
|
||||||
snapshotIDs := testRunList(t, "snapshots", gopts)
|
snapshotIDs := testRunList(t, gopts, "snapshots")
|
||||||
|
|
||||||
m := make(map[string]struct{})
|
m := make(map[string]struct{})
|
||||||
for _, id := range snapshotIDs {
|
for _, id := range snapshotIDs {
|
||||||
|
|||||||
Reference in New Issue
Block a user