mirror of
https://github.com/halejohn/Cloudreve.git
synced 2026-01-26 09:34:57 +08:00
test: search file with limited parent ids
This commit is contained in:
@@ -148,7 +148,7 @@ func GetFilesByKeywords(uid uint, parents []uint, keywords ...interface{}) ([]Fi
|
||||
|
||||
// GetChildFilesOfFolders 批量检索目录子文件
|
||||
func GetChildFilesOfFolders(folders *[]Folder) ([]File, error) {
|
||||
// 将所有待删除目录ID抽离,以便检索文件
|
||||
// 将所有待检索目录ID抽离,以便检索文件
|
||||
folderIDs := make([]uint, 0, len(*folders))
|
||||
for _, value := range *folders {
|
||||
folderIDs = append(folderIDs, value.ID)
|
||||
|
||||
@@ -561,7 +561,7 @@ func TestGetFilesByKeywords(t *testing.T) {
|
||||
// 未指定用户
|
||||
{
|
||||
mock.ExpectQuery("SELECT(.+)").WithArgs("k1", "k2").WillReturnRows(sqlmock.NewRows([]string{"id"}).AddRow(1))
|
||||
res, err := GetFilesByKeywords(0, "k1", "k2")
|
||||
res, err := GetFilesByKeywords(0, nil, "k1", "k2")
|
||||
asserts.NoError(mock.ExpectationsWereMet())
|
||||
asserts.NoError(err)
|
||||
asserts.Len(res, 1)
|
||||
@@ -570,7 +570,16 @@ func TestGetFilesByKeywords(t *testing.T) {
|
||||
// 指定用户
|
||||
{
|
||||
mock.ExpectQuery("SELECT(.+)").WithArgs(1, "k1", "k2").WillReturnRows(sqlmock.NewRows([]string{"id"}).AddRow(1))
|
||||
res, err := GetFilesByKeywords(1, "k1", "k2")
|
||||
res, err := GetFilesByKeywords(1, nil, "k1", "k2")
|
||||
asserts.NoError(mock.ExpectationsWereMet())
|
||||
asserts.NoError(err)
|
||||
asserts.Len(res, 1)
|
||||
}
|
||||
|
||||
// 指定父目录
|
||||
{
|
||||
mock.ExpectQuery("SELECT(.+)").WithArgs(1, 12, "k1", "k2").WillReturnRows(sqlmock.NewRows([]string{"id"}).AddRow(1))
|
||||
res, err := GetFilesByKeywords(1, []uint{12}, "k1", "k2")
|
||||
asserts.NoError(mock.ExpectationsWereMet())
|
||||
asserts.NoError(err)
|
||||
asserts.Len(res, 1)
|
||||
|
||||
@@ -63,6 +63,7 @@ type PolicyOption struct {
|
||||
PlaceholderWithSize bool `json:"placeholder_with_size,omitempty"`
|
||||
}
|
||||
|
||||
// thumbSuffix 支持缩略图处理的文件扩展名
|
||||
var thumbSuffix = map[string][]string{
|
||||
"local": {},
|
||||
"qiniu": {".psd", ".jpg", ".jpeg", ".png", ".gif", ".webp", ".tiff", ".bmp"},
|
||||
|
||||
Reference in New Issue
Block a user