mirror of
https://github.com/cloudreve/cloudreve.git
synced 2025-10-29 23:55:51 +08:00
Feat: after uploading hooks and checks
This commit is contained in:
41
pkg/filesystem/hooks_test.go
Normal file
41
pkg/filesystem/hooks_test.go
Normal file
@ -0,0 +1,41 @@
|
||||
package filesystem
|
||||
|
||||
import (
|
||||
"context"
|
||||
model "github.com/HFO4/cloudreve/models"
|
||||
"github.com/HFO4/cloudreve/pkg/filesystem/local"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestGenericBeforeUpload(t *testing.T) {
|
||||
asserts := assert.New(t)
|
||||
ctx := context.Background()
|
||||
file := local.FileData{
|
||||
Size: 5,
|
||||
Name: "1.txt",
|
||||
}
|
||||
fs := FileSystem{
|
||||
User: &model.User{
|
||||
Storage: 0,
|
||||
Group: model.Group{
|
||||
MaxStorage: 11,
|
||||
},
|
||||
Policy: model.Policy{
|
||||
MaxSize: 4,
|
||||
OptionsSerialized: model.PolicyOption{
|
||||
FileType: []string{"txt"},
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
asserts.Error(GenericBeforeUpload(ctx, &fs, file))
|
||||
file.Size = 1
|
||||
file.Name = "1"
|
||||
asserts.Error(GenericBeforeUpload(ctx, &fs, file))
|
||||
file.Name = "1.txt"
|
||||
asserts.NoError(GenericBeforeUpload(ctx, &fs, file))
|
||||
file.Name = "1.t/xt"
|
||||
asserts.Error(GenericBeforeUpload(ctx, &fs, file))
|
||||
}
|
||||
Reference in New Issue
Block a user