mirror of
https://github.com/restic/restic.git
synced 2026-04-05 04:38:52 +00:00
Rough steps: ``` mv cmd/restic/global* cmd/restic/secondary_repo* internal/global/ sed -i "s/package main/package global/" internal/global/*.go Rename "GlobalOptions" to "Options" in internal/global/ Replace everywhere " GlobalOptions" -> " global.Options" Replace everywhere "\*GlobalOptions" -> " *global.Options" Make SecondaryRepoOptions public Make create public Make version public ```
40 lines
1.2 KiB
Go
40 lines
1.2 KiB
Go
package main
|
|
|
|
import (
|
|
"context"
|
|
"testing"
|
|
|
|
"github.com/restic/restic/internal/global"
|
|
rtest "github.com/restic/restic/internal/test"
|
|
)
|
|
|
|
func testRunRecover(t testing.TB, gopts global.Options) {
|
|
rtest.OK(t, withTermStatus(t, gopts, func(ctx context.Context, gopts global.Options) error {
|
|
return runRecover(context.TODO(), gopts, gopts.Term)
|
|
}))
|
|
}
|
|
|
|
func TestRecover(t *testing.T) {
|
|
env, cleanup := withTestEnvironment(t)
|
|
// must list index more than once
|
|
env.gopts.BackendTestHook = nil
|
|
defer cleanup()
|
|
|
|
testSetupBackupData(t, env)
|
|
|
|
// create backup and forget it afterwards
|
|
testRunBackup(t, "", []string{env.testdata}, BackupOptions{}, env.gopts)
|
|
ids := testListSnapshots(t, env.gopts, 1)
|
|
sn := testLoadSnapshot(t, env.gopts, ids[0])
|
|
testRunForget(t, env.gopts, ForgetOptions{}, ids[0].String())
|
|
testListSnapshots(t, env.gopts, 0)
|
|
|
|
testRunRecover(t, env.gopts)
|
|
ids = testListSnapshots(t, env.gopts, 1)
|
|
testRunCheck(t, env.gopts)
|
|
// check that the root tree is included in the snapshot
|
|
rtest.OK(t, withTermStatus(t, env.gopts, func(ctx context.Context, gopts global.Options) error {
|
|
return runCat(context.TODO(), gopts, []string{"tree", ids[0].String() + ":" + sn.Tree.Str()}, gopts.Term)
|
|
}))
|
|
}
|