lock: add Refresh method

This commit is contained in:
Alexander Neumann committed 2015-07-12 21:02:00 +02:00
1 parent 2cc5318c46
commit 781ec903e8
2 files changed
+56 -5

No files matched your search

+30
View File
@@ -195,3 +195,33 @@ func TestRemoveAllLocks(t *testing.T) {
Assert(t, lockExists(repo, t, id3) == false,
"lock still exists after RemoveAllLocks was called")
}
func TestLockRefresh(t *testing.T) {
repo := SetupRepo()
defer TeardownRepo(repo)
lock, err := restic.NewLock(repo)
OK(t, err)
var lockID backend.ID
for id := range repo.List(backend.Lock, nil) {
if lockID != nil {
t.Error("more than one lock found")
}
lockID = id
}
OK(t, lock.Refresh())
var lockID2 backend.ID
for id := range repo.List(backend.Lock, nil) {
if lockID2 != nil {
t.Error("more than one lock found")
}
lockID2 = id
}
Assert(t, !lockID.Equal(lockID2),
"expected a new ID after lock refresh, got the same")
OK(t, lock.Unlock())
}