mirror of
https://github.com/restic/restic.git
synced 2026-02-03 12:29:37 -05: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 ```
36 lines
941 B
Go
36 lines
941 B
Go
package main
|
|
|
|
import (
|
|
"context"
|
|
"testing"
|
|
|
|
"github.com/restic/restic/internal/global"
|
|
rtest "github.com/restic/restic/internal/test"
|
|
)
|
|
|
|
func testRunCheck(t testing.TB, gopts global.Options) {
|
|
t.Helper()
|
|
output, err := testRunCheckOutput(t, gopts, true)
|
|
if err != nil {
|
|
t.Error(output)
|
|
t.Fatalf("unexpected error: %+v", err)
|
|
}
|
|
}
|
|
|
|
func testRunCheckMustFail(t testing.TB, gopts global.Options) {
|
|
t.Helper()
|
|
_, err := testRunCheckOutput(t, gopts, false)
|
|
rtest.Assert(t, err != nil, "expected non nil error after check of damaged repository")
|
|
}
|
|
|
|
func testRunCheckOutput(t testing.TB, gopts global.Options, checkUnused bool) (string, error) {
|
|
buf, err := withCaptureStdout(t, gopts, func(ctx context.Context, gopts global.Options) error {
|
|
opts := CheckOptions{
|
|
ReadData: true,
|
|
CheckUnused: checkUnused,
|
|
}
|
|
_, err := runCheck(context.TODO(), opts, gopts, nil, gopts.Term)
|
|
return err
|
|
})
|
|
return buf.String(), err
|
|
}
|