28 lines
608 B
Go
28 lines
608 B
Go
|
package lockingstore
|
||
|
|
||
|
import (
|
||
|
"testing"
|
||
|
|
||
|
"github.com/tus/tusd"
|
||
|
)
|
||
|
|
||
|
func TestMemoryLocker(t *testing.T) {
|
||
|
locker := New()
|
||
|
|
||
|
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)
|
||
|
}
|
||
|
}
|