mirror of
https://github.com/restic/restic.git
synced 2026-11-07 08:43:07 +00:00
lock: add Refresh method
This commit is contained in:
1 parent
2cc5318c46
commit
781ec903e8
2 files changed
+56
-5
No files matched your search
@@ -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())
|
||||
}
|
||||
Reference in new issue
Block a user