mirror of
https://github.com/halejohn/Cloudreve.git
synced 2026-01-26 09:34:57 +08:00
Test: file compress / download
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
package model
|
||||
|
||||
import (
|
||||
"encoding/gob"
|
||||
"github.com/HFO4/cloudreve/pkg/util"
|
||||
"github.com/jinzhu/gorm"
|
||||
"path"
|
||||
@@ -25,6 +26,11 @@ type File struct {
|
||||
Position string `gorm:"-"`
|
||||
}
|
||||
|
||||
func init() {
|
||||
// 注册缓存用到的复杂结构
|
||||
gob.Register(File{})
|
||||
}
|
||||
|
||||
// Create 创建文件记录
|
||||
func (file *File) Create() (uint, error) {
|
||||
if err := DB.Create(file).Error; err != nil {
|
||||
|
||||
@@ -64,6 +64,8 @@ func TestFolder_GetChildFiles(t *testing.T) {
|
||||
Model: gorm.Model{
|
||||
ID: 1,
|
||||
},
|
||||
Position: "/123",
|
||||
Name: "456",
|
||||
}
|
||||
|
||||
// 找不到
|
||||
@@ -78,6 +80,7 @@ func TestFolder_GetChildFiles(t *testing.T) {
|
||||
files, err = folder.GetChildFiles()
|
||||
asserts.NoError(err)
|
||||
asserts.Len(files, 2)
|
||||
asserts.Equal("/123/456", files[0].Position)
|
||||
asserts.NoError(mock.ExpectationsWereMet())
|
||||
|
||||
}
|
||||
|
||||
@@ -73,6 +73,8 @@ func TestFolder_GetChildFolder(t *testing.T) {
|
||||
Model: gorm.Model{
|
||||
ID: 1,
|
||||
},
|
||||
Position: "/123",
|
||||
Name: "456",
|
||||
}
|
||||
|
||||
// 找不到
|
||||
@@ -87,6 +89,7 @@ func TestFolder_GetChildFolder(t *testing.T) {
|
||||
files, err = folder.GetChildFolder()
|
||||
asserts.NoError(err)
|
||||
asserts.Len(files, 2)
|
||||
asserts.Equal("/123/456", files[0].Position)
|
||||
asserts.NoError(mock.ExpectationsWereMet())
|
||||
}
|
||||
|
||||
|
||||
@@ -67,6 +67,9 @@ func addDefaultPolicy() {
|
||||
DirNameRule: "uploads/{uid}/{path}",
|
||||
FileNameRule: "{uid}_{randomkey8}_{originname}",
|
||||
IsOriginLinkEnable: false,
|
||||
OptionsSerialized: PolicyOption{
|
||||
FileType: []string{},
|
||||
},
|
||||
}
|
||||
if err := DB.Create(&defaultPolicy).Error; err != nil {
|
||||
util.Log().Panic("无法创建初始存储策略, %s", err)
|
||||
@@ -76,7 +79,7 @@ func addDefaultPolicy() {
|
||||
|
||||
func addDefaultSettings() {
|
||||
defaultSettings := []Setting{
|
||||
{Name: "siteURL", Value: `http://lite.aoaoao.me/`, Type: "basic"},
|
||||
{Name: "siteURL", Value: ``, Type: "basic"},
|
||||
{Name: "siteName", Value: `Cloudreve`, Type: "basic"},
|
||||
{Name: "siteStatus", Value: `open`, Type: "basic"},
|
||||
{Name: "regStatus", Value: `0`, Type: "register"},
|
||||
|
||||
Reference in New Issue
Block a user