mirror of
https://github.com/halejohn/Cloudreve.git
synced 2026-01-26 09:34:57 +08:00
test: fix failed test
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
package filesystem
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"context"
|
||||
"errors"
|
||||
"github.com/cloudreve/Cloudreve/v3/pkg/request"
|
||||
@@ -58,12 +59,11 @@ func TestFileSystem_Compress(t *testing.T) {
|
||||
)
|
||||
// 查找上传策略
|
||||
asserts.NoError(cache.Set("policy_1", model.Policy{Type: "local"}, -1))
|
||||
w := &bytes.Buffer{}
|
||||
|
||||
zipFile, err := fs.Compress(ctx, []uint{1}, []uint{1}, true)
|
||||
err := fs.Compress(ctx, w, []uint{1}, []uint{1}, true)
|
||||
asserts.NoError(err)
|
||||
asserts.NotEmpty(zipFile)
|
||||
asserts.Contains(zipFile, "archive_")
|
||||
asserts.Contains(zipFile, "tests")
|
||||
asserts.NotEmpty(w.Len())
|
||||
}
|
||||
|
||||
// 上下文取消
|
||||
@@ -84,9 +84,10 @@ func TestFileSystem_Compress(t *testing.T) {
|
||||
)
|
||||
asserts.NoError(cache.Set("setting_temp_path", "tests", -1))
|
||||
|
||||
zipFile, err := fs.Compress(ctx, []uint{1}, []uint{1}, true)
|
||||
w := &bytes.Buffer{}
|
||||
err := fs.Compress(ctx, w, []uint{1}, []uint{1}, true)
|
||||
asserts.Error(err)
|
||||
asserts.Empty(zipFile)
|
||||
asserts.NotEmpty(w.Len())
|
||||
}
|
||||
|
||||
// 限制父目录
|
||||
@@ -108,10 +109,11 @@ func TestFileSystem_Compress(t *testing.T) {
|
||||
)
|
||||
asserts.NoError(cache.Set("setting_temp_path", "tests", -1))
|
||||
|
||||
zipFile, err := fs.Compress(ctx, []uint{1}, []uint{1}, true)
|
||||
w := &bytes.Buffer{}
|
||||
err := fs.Compress(ctx, w, []uint{1}, []uint{1}, true)
|
||||
asserts.Error(err)
|
||||
asserts.Equal(ErrObjectNotExist, err)
|
||||
asserts.Empty(zipFile)
|
||||
asserts.Empty(w.Len())
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -122,7 +122,7 @@ func (job *CompressTask) Do() {
|
||||
|
||||
job.zipPath = zipFilePath
|
||||
zipFile.Close()
|
||||
util.Log().Debug("压缩文件存放至%s,开始上传", zipFile)
|
||||
util.Log().Debug("压缩文件存放至%s,开始上传", zipFilePath)
|
||||
job.TaskModel.SetProgress(TransferringProgress)
|
||||
|
||||
// 上传文件
|
||||
|
||||
Reference in New Issue
Block a user