示例#1
0
func TestCheckerModifiedData(t *testing.T) {
	be := backend.NewMemoryBackend()

	repo := repository.New(be)
	OK(t, repo.Init(TestPassword))

	arch := restic.NewArchiver(repo)
	_, id, err := arch.Snapshot(nil, []string{"."}, nil)
	OK(t, err)
	t.Logf("archived as %v", id.Str())

	checkRepo := repository.New(errorBackend{be})
	OK(t, checkRepo.SearchKey(TestPassword))

	chkr := checker.New(checkRepo)

	hints, errs := chkr.LoadIndex()
	if len(errs) > 0 {
		t.Fatalf("expected no errors, got %v: %v", len(errs), errs)
	}

	if len(hints) > 0 {
		t.Errorf("expected no hints, got %v: %v", len(hints), hints)
	}

	errFound := false
	for _, err := range checkPacks(chkr) {
		t.Logf("pack error: %v", err)
	}

	for _, err := range checkStruct(chkr) {
		t.Logf("struct error: %v", err)
	}

	for _, err := range checkData(chkr) {
		t.Logf("struct error: %v", err)
		errFound = true
	}

	if !errFound {
		t.Fatal("no error found, checker is broken")
	}
}
示例#2
0
func TestMemoryBackend(t *testing.T) {
	be := backend.NewMemoryBackend()
	testBackend(be, t)
}