2
2
mirror of https://github.com/octoleo/restic.git synced 2024-05-31 08:00:48 +00:00
restic/src/restic/testing_test.go

61 lines
1.1 KiB
Go
Raw Normal View History

2016-04-10 14:52:15 +00:00
package restic_test
import (
"restic"
"restic/checker"
"restic/repository"
"testing"
"time"
)
var testSnapshotTime = time.Unix(1460289341, 207401672)
func TestCreateSnapshot(t *testing.T) {
repo, cleanup := repository.TestRepository(t)
defer cleanup()
restic.TestCreateSnapshot(t, repo, testSnapshotTime)
snapshots, err := restic.LoadAllSnapshots(repo)
if err != nil {
t.Fatal(err)
}
if len(snapshots) != 1 {
t.Fatalf("got %d snapshots, expected %d", len(snapshots), 1)
}
sn := snapshots[0]
if sn.Time != testSnapshotTime {
t.Fatalf("got timestamp %v, expected %v", sn.Time, testSnapshotTime)
}
if sn.Tree == nil {
t.Fatalf("tree id is nil")
}
if sn.Tree.IsNull() {
t.Fatalf("snapshot has zero tree ID")
}
chkr := checker.New(repo)
hints, errs := chkr.LoadIndex()
if len(errs) != 0 {
t.Fatalf("errors loading index: %v", errs)
}
if len(hints) != 0 {
t.Fatalf("errors loading index: %v", hints)
}
done := make(chan struct{})
defer close(done)
errChan := make(chan error)
go chkr.Structure(errChan, done)
for err := range errChan {
t.Error(err)
}
}