mirror of
https://github.com/garethgeorge/backrest.git
synced 2025-12-13 09:15:39 +00:00
feat: support restic check operation (#303)
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
package repo
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"context"
|
||||
"os"
|
||||
"slices"
|
||||
@@ -189,3 +190,59 @@ func TestEnvVarPropagation(t *testing.T) {
|
||||
t.Fatal("expected snapshot id")
|
||||
}
|
||||
}
|
||||
|
||||
func TestCheck(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
tcs := []struct {
|
||||
name string
|
||||
repo *v1.Repo
|
||||
}{
|
||||
{
|
||||
name: "check structure",
|
||||
repo: &v1.Repo{
|
||||
Id: "test",
|
||||
Uri: t.TempDir(),
|
||||
Password: "test",
|
||||
CheckPolicy: &v1.CheckPolicy{
|
||||
Mode: nil,
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "read data percent",
|
||||
repo: &v1.Repo{
|
||||
Id: "test",
|
||||
Uri: t.TempDir(),
|
||||
Password: "test",
|
||||
CheckPolicy: &v1.CheckPolicy{
|
||||
Mode: &v1.CheckPolicy_ReadDataSubsetPercent{
|
||||
ReadDataSubsetPercent: 50,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
for _, tc := range tcs {
|
||||
t.Run(tc.name, func(t *testing.T) {
|
||||
orchestrator, err := NewRepoOrchestrator(configForTest, tc.repo, helpers.ResticBinary(t))
|
||||
if err != nil {
|
||||
t.Fatalf("failed to create repo orchestrator: %v", err)
|
||||
}
|
||||
|
||||
buf := bytes.NewBuffer(nil)
|
||||
|
||||
err = orchestrator.Init(context.Background())
|
||||
if err != nil {
|
||||
t.Fatalf("init error: %v", err)
|
||||
}
|
||||
|
||||
err = orchestrator.Check(context.Background(), buf)
|
||||
if err != nil {
|
||||
t.Errorf("check error: %v", err)
|
||||
}
|
||||
t.Logf("check output: %s", buf.String())
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user