mirror of
https://github.com/restic/restic.git
synced 2026-09-11 06:57:58 +00:00
rewrite: cleanup new metadata options and fix no parameters check
This commit is contained in:
@@ -9,13 +9,13 @@ import (
|
||||
rtest "github.com/restic/restic/internal/test"
|
||||
)
|
||||
|
||||
func testRunRewriteExclude(t testing.TB, gopts GlobalOptions, excludes []string, forget bool, metadata *SnapshotMetadataArgs) {
|
||||
func testRunRewriteExclude(t testing.TB, gopts GlobalOptions, excludes []string, forget bool, metadata snapshotMetadataArgs) {
|
||||
opts := RewriteOptions{
|
||||
excludePatternOptions: excludePatternOptions{
|
||||
Excludes: excludes,
|
||||
},
|
||||
Forget: forget,
|
||||
Metadata: metadata,
|
||||
metadata: metadata,
|
||||
}
|
||||
|
||||
rtest.OK(t, runRewrite(context.TODO(), opts, gopts, nil))
|
||||
@@ -39,7 +39,7 @@ func TestRewrite(t *testing.T) {
|
||||
createBasicRewriteRepo(t, env)
|
||||
|
||||
// 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)
|
||||
rtest.Assert(t, len(snapshotIDs) == 2, "expected two snapshots, got %v", snapshotIDs)
|
||||
testRunCheck(t, env.gopts)
|
||||
@@ -51,7 +51,7 @@ func TestRewriteUnchanged(t *testing.T) {
|
||||
snapshotID := createBasicRewriteRepo(t, env)
|
||||
|
||||
// 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)
|
||||
rtest.Assert(t, len(newSnapshotIDs) == 1, "expected one snapshot, got %v", newSnapshotIDs)
|
||||
rtest.Assert(t, snapshotID == newSnapshotIDs[0], "snapshot id changed unexpectedly")
|
||||
@@ -64,7 +64,7 @@ func TestRewriteReplace(t *testing.T) {
|
||||
snapshotID := createBasicRewriteRepo(t, env)
|
||||
|
||||
// exclude some data
|
||||
testRunRewriteExclude(t, env.gopts, []string{"3"}, true, &SnapshotMetadataArgs{Hostname: "", Time: ""})
|
||||
testRunRewriteExclude(t, env.gopts, []string{"3"}, true, snapshotMetadataArgs{Hostname: "", Time: ""})
|
||||
newSnapshotIDs := testRunList(t, "snapshots", env.gopts)
|
||||
rtest.Assert(t, len(newSnapshotIDs) == 1, "expected one snapshot, got %v", newSnapshotIDs)
|
||||
rtest.Assert(t, snapshotID != newSnapshotIDs[0], "snapshot id should have changed")
|
||||
@@ -73,14 +73,14 @@ func TestRewriteReplace(t *testing.T) {
|
||||
testRunCheck(t, env.gopts)
|
||||
}
|
||||
|
||||
func testRewriteMetadata(t *testing.T, metadata SnapshotMetadataArgs) {
|
||||
func testRewriteMetadata(t *testing.T, metadata snapshotMetadataArgs) {
|
||||
env, cleanup := withTestEnvironment(t)
|
||||
env.gopts.backendTestHook = nil
|
||||
defer cleanup()
|
||||
createBasicRewriteRepo(t, env)
|
||||
repo, _ := OpenRepository(context.TODO(), env.gopts)
|
||||
|
||||
testRunRewriteExclude(t, env.gopts, []string{}, true, &metadata)
|
||||
testRunRewriteExclude(t, env.gopts, []string{}, true, metadata)
|
||||
|
||||
snapshots := FindFilteredSnapshots(context.TODO(), repo, repo, &restic.SnapshotFilter{}, []string{})
|
||||
|
||||
@@ -99,7 +99,7 @@ func TestRewriteMetadata(t *testing.T) {
|
||||
newHost := "new host"
|
||||
newTime := "1999-01-01 11:11:11"
|
||||
|
||||
for _, metadata := range []SnapshotMetadataArgs{
|
||||
for _, metadata := range []snapshotMetadataArgs{
|
||||
{Hostname: "", Time: newTime},
|
||||
{Hostname: newHost, Time: ""},
|
||||
{Hostname: newHost, Time: newTime},
|
||||
|
||||
Reference in New Issue
Block a user