tusd/lockingstore/memorylocker_test.go

29 lines
638 B
Go
Raw Normal View History

2015-12-09 19:48:41 +00:00
package lockingstore
import (
"testing"
"github.com/tus/tusd"
)
func TestMemoryLocker(t *testing.T) {
var locker Locker
2015-12-18 22:21:13 +00:00
locker = NewMemoryLocker()
2015-12-09 19:48:41 +00:00
if err := locker.LockUpload("one"); err != nil {
t.Errorf("unexpected error when locking file: %s", err)
}
if err := locker.LockUpload("one"); err != tusd.ErrFileLocked {
t.Errorf("expected error when locking locked file: %s", err)
}
if err := locker.UnlockUpload("one"); err != nil {
t.Errorf("unexpected error when unlocking file: %s", err)
}
if err := locker.UnlockUpload("one"); err != nil {
t.Errorf("unexpected error when unlocking file again: %s", err)
}
}