Feat: file uploading in slave mode
This commit is contained in:
@@ -7,6 +7,7 @@ import (
|
||||
"github.com/HFO4/cloudreve/pkg/filesystem/fsctx"
|
||||
"github.com/HFO4/cloudreve/pkg/filesystem/local"
|
||||
"github.com/HFO4/cloudreve/pkg/filesystem/response"
|
||||
"github.com/HFO4/cloudreve/pkg/serializer"
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/jinzhu/gorm"
|
||||
"github.com/stretchr/testify/assert"
|
||||
@@ -139,3 +140,22 @@ func TestFileSystem_Upload(t *testing.T) {
|
||||
testHandller2.AssertExpectations(t)
|
||||
|
||||
}
|
||||
|
||||
func TestFileSystem_GenerateSavePath_Anonymous(t *testing.T) {
|
||||
asserts := assert.New(t)
|
||||
fs := FileSystem{User: &model.User{}}
|
||||
ctx := context.WithValue(
|
||||
context.Background(),
|
||||
fsctx.UploadPolicyCtx,
|
||||
serializer.UploadPolicy{
|
||||
SavePath: "{randomkey16}",
|
||||
AutoRename: false,
|
||||
},
|
||||
)
|
||||
|
||||
savePath := fs.GenerateSavePath(ctx, local.FileStream{
|
||||
Name: "test.test",
|
||||
})
|
||||
asserts.Len(savePath, 26)
|
||||
asserts.Contains(savePath, "test.test")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user