提交 297fc8d5 编写于 作者: H HFO4

Fix: failed test due to relative path

上级 71876a79
......@@ -501,7 +501,8 @@ func TestFileSystem_Preview(t *testing.T) {
}
fs.FileTarget = []model.File{
{
PolicyID: 1,
SourceName: "tests/no.txt",
PolicyID: 1,
Policy: model.Policy{
Model: gorm.Model{ID: 1},
Type: "local",
......@@ -529,10 +530,8 @@ func TestFileSystem_Preview(t *testing.T) {
},
}
resp, err := fs.Preview(ctx, 1, false)
asserts.NoError(err)
asserts.NotNil(resp)
asserts.False(resp.Redirect)
asserts.NoError(resp.Content.Close())
asserts.Error(err)
asserts.Nil(resp)
}
// 需要重定向,成功
......
......@@ -9,6 +9,7 @@ import (
"github.com/HFO4/cloudreve/pkg/conf"
"github.com/HFO4/cloudreve/pkg/filesystem/fsctx"
"github.com/HFO4/cloudreve/pkg/serializer"
"github.com/HFO4/cloudreve/pkg/util"
"github.com/jinzhu/gorm"
"github.com/stretchr/testify/assert"
"os"
......@@ -350,8 +351,8 @@ func TestFileSystem_Delete(t *testing.T) {
//全部成功
{
fs.CleanTargets()
file, err := os.Create("1.txt")
file2, err := os.Create("2.txt")
file, err := os.Create(util.RelativePath("1.txt"))
file2, err := os.Create(util.RelativePath("2.txt"))
file.Close()
file2.Close()
asserts.NoError(err)
......
......@@ -112,6 +112,7 @@ func TestFileSystem_Upload(t *testing.T) {
Size: 5,
VirtualPath: "/",
Name: "1.txt",
File: ioutil.NopCloser(strings.NewReader("")),
}
err = fs.Upload(ctx, file)
asserts.NoError(err)
......
......@@ -61,11 +61,6 @@ func TestFileSystem_ValidateCapacity(t *testing.T) {
fs.User.Storage = 5
asserts.False(fs.ValidateCapacity(ctx, 10))
asserts.Equal(uint64(5), fs.User.Storage)
fs.User.Storage = 5
cache.Set("pack_size_0", uint64(15), 0)
asserts.True(fs.ValidateCapacity(ctx, 10))
asserts.Equal(uint64(15), fs.User.Storage)
}
func TestFileSystem_ValidateFileSize(t *testing.T) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册