From e9b61493031413db3c521acd543006e89d0ada77 Mon Sep 17 00:00:00 2001 From: Michael Eischer Date: Sun, 14 Sep 2025 13:50:06 +0200 Subject: [PATCH] list: cleanup parameter order of test helper --- cmd/restic/cmd_backup_integration_test.go | 20 +++++++++---------- cmd/restic/cmd_list_integration_test.go | 6 +++--- cmd/restic/cmd_mount_integration_test.go | 6 +++--- .../cmd_repair_snapshots_integration_test.go | 4 ++-- cmd/restic/cmd_rewrite_integration_test.go | 6 +++--- cmd/restic/integration_helpers_test.go | 2 +- 6 files changed, 22 insertions(+), 22 deletions(-) diff --git a/cmd/restic/cmd_backup_integration_test.go b/cmd/restic/cmd_backup_integration_test.go index 0002b207f..c0b6adbdf 100644 --- a/cmd/restic/cmd_backup_integration_test.go +++ b/cmd/restic/cmd_backup_integration_test.go @@ -218,41 +218,41 @@ func TestDryRunBackup(t *testing.T) { // dry run before first backup testRunBackup(t, filepath.Dir(env.testdata), []string{"testdata"}, dryOpts, env.gopts) snapshotIDs := testListSnapshots(t, env.gopts, 0) - packIDs := testRunList(t, "packs", env.gopts) + packIDs := testRunList(t, env.gopts, "packs") rtest.Assert(t, len(packIDs) == 0, "expected no data, got %v", snapshotIDs) - indexIDs := testRunList(t, "index", env.gopts) + indexIDs := testRunList(t, env.gopts, "index") rtest.Assert(t, len(indexIDs) == 0, "expected no index, got %v", snapshotIDs) // first backup testRunBackup(t, filepath.Dir(env.testdata), []string{"testdata"}, opts, env.gopts) snapshotIDs = testListSnapshots(t, env.gopts, 1) - packIDs = testRunList(t, "packs", env.gopts) - indexIDs = testRunList(t, "index", env.gopts) + packIDs = testRunList(t, env.gopts, "packs") + indexIDs = testRunList(t, env.gopts, "index") // dry run between backups testRunBackup(t, filepath.Dir(env.testdata), []string{"testdata"}, dryOpts, env.gopts) snapshotIDsAfter := testListSnapshots(t, env.gopts, 1) rtest.Equals(t, snapshotIDs, snapshotIDsAfter) - dataIDsAfter := testRunList(t, "packs", env.gopts) + dataIDsAfter := testRunList(t, env.gopts, "packs") rtest.Equals(t, packIDs, dataIDsAfter) - indexIDsAfter := testRunList(t, "index", env.gopts) + indexIDsAfter := testRunList(t, env.gopts, "index") rtest.Equals(t, indexIDs, indexIDsAfter) // second backup, implicit incremental testRunBackup(t, filepath.Dir(env.testdata), []string{"testdata"}, opts, env.gopts) snapshotIDs = testListSnapshots(t, env.gopts, 2) - packIDs = testRunList(t, "packs", env.gopts) - indexIDs = testRunList(t, "index", env.gopts) + packIDs = testRunList(t, env.gopts, "packs") + indexIDs = testRunList(t, env.gopts, "index") // another dry run testRunBackup(t, filepath.Dir(env.testdata), []string{"testdata"}, dryOpts, env.gopts) snapshotIDsAfter = testListSnapshots(t, env.gopts, 2) rtest.Equals(t, snapshotIDs, snapshotIDsAfter) - dataIDsAfter = testRunList(t, "packs", env.gopts) + dataIDsAfter = testRunList(t, env.gopts, "packs") rtest.Equals(t, packIDs, dataIDsAfter) - indexIDsAfter = testRunList(t, "index", env.gopts) + indexIDsAfter = testRunList(t, env.gopts, "index") rtest.Equals(t, indexIDs, indexIDsAfter) } diff --git a/cmd/restic/cmd_list_integration_test.go b/cmd/restic/cmd_list_integration_test.go index ef2b8bf8f..0257a13f1 100644 --- a/cmd/restic/cmd_list_integration_test.go +++ b/cmd/restic/cmd_list_integration_test.go @@ -10,9 +10,9 @@ import ( 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 { - return runList(context.TODO(), opts, []string{tpe}) + return runList(context.TODO(), gopts, []string{tpe}) }) rtest.OK(t, err) 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 { 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) return snapshotIDs } diff --git a/cmd/restic/cmd_mount_integration_test.go b/cmd/restic/cmd_mount_integration_test.go index c5f4d193a..317712576 100644 --- a/cmd/restic/cmd_mount_integration_test.go +++ b/cmd/restic/cmd_mount_integration_test.go @@ -177,7 +177,7 @@ func TestMount(t *testing.T) { // first backup 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, "expected one snapshot, got %v", snapshotIDs) @@ -185,7 +185,7 @@ func TestMount(t *testing.T) { // second backup, implicit incremental 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, "expected two snapshots, got %v", snapshotIDs) @@ -194,7 +194,7 @@ func TestMount(t *testing.T) { // third backup, explicit incremental bopts := BackupOptions{Parent: snapshotIDs[0].String()} 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, "expected three snapshots, got %v", snapshotIDs) diff --git a/cmd/restic/cmd_repair_snapshots_integration_test.go b/cmd/restic/cmd_repair_snapshots_integration_test.go index 9f65c9328..05ad1868d 100644 --- a/cmd/restic/cmd_repair_snapshots_integration_test.go +++ b/cmd/restic/cmd_repair_snapshots_integration_test.go @@ -77,7 +77,7 @@ func TestRepairSnapshotsWithLostTree(t *testing.T) { createRandomFile(t, env, "foo/bar/file", 12345) testRunBackup(t, "", []string{env.testdata}, BackupOptions{}, env.gopts) oldSnapshot := testListSnapshots(t, env.gopts, 1) - oldPacks := testRunList(t, "packs", env.gopts) + oldPacks := testRunList(t, env.gopts, "packs") // keep foo/bar unchanged createRandomFile(t, env, "foo/bar2", 1024) @@ -106,7 +106,7 @@ func TestRepairSnapshotsWithLostRootTree(t *testing.T) { createRandomFile(t, env, "foo/bar/file", 12345) testRunBackup(t, "", []string{env.testdata}, BackupOptions{}, env.gopts) testListSnapshots(t, env.gopts, 1) - oldPacks := testRunList(t, "packs", env.gopts) + oldPacks := testRunList(t, env.gopts, "packs") // remove all trees removePacks(env.gopts, t, restic.NewIDSet(oldPacks...)) diff --git a/cmd/restic/cmd_rewrite_integration_test.go b/cmd/restic/cmd_rewrite_integration_test.go index 188353333..18313cec6 100644 --- a/cmd/restic/cmd_rewrite_integration_test.go +++ b/cmd/restic/cmd_rewrite_integration_test.go @@ -28,7 +28,7 @@ func createBasicRewriteRepo(t testing.TB, env *testEnvironment) restic.ID { // create backup 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) testRunCheck(t, env.gopts) @@ -60,7 +60,7 @@ func TestRewrite(t *testing.T) { // exclude some data 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) testRunCheck(t, env.gopts) } @@ -72,7 +72,7 @@ func TestRewriteUnchanged(t *testing.T) { // use an exclude that will not exclude anything 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, snapshotID == newSnapshotIDs[0], "snapshot id changed unexpectedly") testRunCheck(t, env.gopts) diff --git a/cmd/restic/integration_helpers_test.go b/cmd/restic/integration_helpers_test.go index dff84522a..71556e55f 100644 --- a/cmd/restic/integration_helpers_test.go +++ b/cmd/restic/integration_helpers_test.go @@ -333,7 +333,7 @@ func includes(haystack []string, needle string) bool { } 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{}) for _, id := range snapshotIDs {