mirror of
https://github.com/octoleo/restic.git
synced 2024-12-25 20:11:06 +00:00
35 lines
795 B
Go
35 lines
795 B
Go
package main
|
|
|
|
import (
|
|
"context"
|
|
"testing"
|
|
|
|
rtest "github.com/restic/restic/internal/test"
|
|
)
|
|
|
|
func testRunCheck(t testing.TB, gopts GlobalOptions) {
|
|
t.Helper()
|
|
output, err := testRunCheckOutput(gopts, true)
|
|
if err != nil {
|
|
t.Error(output)
|
|
t.Fatalf("unexpected error: %+v", err)
|
|
}
|
|
}
|
|
|
|
func testRunCheckMustFail(t testing.TB, gopts GlobalOptions) {
|
|
t.Helper()
|
|
_, err := testRunCheckOutput(gopts, false)
|
|
rtest.Assert(t, err != nil, "expected non nil error after check of damaged repository")
|
|
}
|
|
|
|
func testRunCheckOutput(gopts GlobalOptions, checkUnused bool) (string, error) {
|
|
buf, err := withCaptureStdout(func() error {
|
|
opts := CheckOptions{
|
|
ReadData: true,
|
|
CheckUnused: checkUnused,
|
|
}
|
|
return runCheck(context.TODO(), opts, gopts, nil)
|
|
})
|
|
return buf.String(), err
|
|
}
|