|
|
|
@ -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())
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|