2015-12-09 19:48:41 +00:00
|
|
|
package lockingstore
|
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
|
|
|
|
|
|
|
"github.com/tus/tusd"
|
|
|
|
)
|
|
|
|
|
|
|
|
func TestMemoryLocker(t *testing.T) {
|
2015-12-15 21:04:12 +00:00
|
|
|
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)
|
|
|
|
}
|
|
|
|
}
|