mirror of
https://github.com/simon987/ws_bucket.git
synced 2025-12-14 07:09:07 +00:00
Indicate duplicate upload slots to the client
This commit is contained in:
@@ -4,6 +4,7 @@ import (
|
||||
"github.com/jinzhu/gorm"
|
||||
_ "github.com/jinzhu/gorm/dialects/sqlite"
|
||||
"github.com/simon987/ws_bucket/api"
|
||||
"os"
|
||||
"testing"
|
||||
"time"
|
||||
)
|
||||
@@ -22,4 +23,5 @@ func TestMain(m *testing.M) {
|
||||
time.Sleep(time.Millisecond * 100)
|
||||
|
||||
m.Run()
|
||||
_ = os.Remove("test.db")
|
||||
}
|
||||
|
||||
@@ -46,6 +46,25 @@ func TestAllocateUploadSlotUnsafePath(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestDuplicateUploadSlot(t *testing.T) {
|
||||
|
||||
if allocateUploadSlot(api.AllocateUploadSlotRequest{
|
||||
FileName: "test.png",
|
||||
Token: "testdupe",
|
||||
MaxSize: 100,
|
||||
}).Ok != true {
|
||||
t.Error()
|
||||
}
|
||||
|
||||
if allocateUploadSlot(api.AllocateUploadSlotRequest{
|
||||
FileName: "test.png",
|
||||
Token: "testdupe",
|
||||
MaxSize: 100,
|
||||
}).Ok != false {
|
||||
t.Error()
|
||||
}
|
||||
}
|
||||
|
||||
func allocateUploadSlot(request api.AllocateUploadSlotRequest) (ar *api.GenericResponse) {
|
||||
resp := Post("/slot", request)
|
||||
UnmarshalResponse(resp, &ar)
|
||||
|
||||
Reference in New Issue
Block a user