mirror of
https://github.com/halejohn/Cloudreve.git
synced 2026-01-26 09:34:57 +08:00
Fix: directory renaming should not be limited by file extensions (#395)
This commit is contained in:
@@ -707,12 +707,39 @@ func TestFileSystem_Rename(t *testing.T) {
|
||||
asserts.Equal(ErrPathNotExist, err)
|
||||
}
|
||||
|
||||
// 新名字不合法
|
||||
// 新名字是目录,不合法
|
||||
{
|
||||
err := fs.Rename(ctx, []uint{10}, []uint{}, "ne/w")
|
||||
asserts.Error(err)
|
||||
asserts.Equal(ErrIllegalObjectName, err)
|
||||
}
|
||||
|
||||
// 新名字是文件,不合法
|
||||
{
|
||||
err := fs.Rename(ctx, []uint{}, []uint{10}, "ne/w")
|
||||
asserts.Error(err)
|
||||
asserts.Equal(ErrIllegalObjectName, err)
|
||||
}
|
||||
|
||||
// 新名字是文件,扩展名不合法
|
||||
{
|
||||
fs.User.Policy.OptionsSerialized.FileType = []string{"txt"}
|
||||
err := fs.Rename(ctx, []uint{}, []uint{10}, "1.jpg")
|
||||
asserts.Error(err)
|
||||
asserts.Equal(ErrIllegalObjectName, err)
|
||||
}
|
||||
|
||||
// 新名字是目录,不应该检测扩展名
|
||||
{
|
||||
fs.User.Policy.OptionsSerialized.FileType = []string{"txt"}
|
||||
mock.ExpectQuery("SELECT(.+)folders(.+)").
|
||||
WithArgs(10, 1).
|
||||
WillReturnRows(sqlmock.NewRows([]string{"id", "name"}))
|
||||
err := fs.Rename(ctx, []uint{10}, []uint{}, "new")
|
||||
asserts.NoError(mock.ExpectationsWereMet())
|
||||
asserts.Error(err)
|
||||
asserts.Equal(ErrPathNotExist, err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestFileSystem_SaveTo(t *testing.T) {
|
||||
|
||||
Reference in New Issue
Block a user