test: fix failed ut
This commit is contained in:
parent
b9143b53f6
commit
00d56d6d07
2 changed files with 8 additions and 20 deletions
|
@ -8,7 +8,6 @@ import (
|
|||
"github.com/cloudreve/Cloudreve/v3/pkg/filesystem/driver"
|
||||
"github.com/cloudreve/Cloudreve/v3/pkg/filesystem/response"
|
||||
"github.com/cloudreve/Cloudreve/v3/pkg/mocks/thumbmock"
|
||||
"github.com/cloudreve/Cloudreve/v3/pkg/request"
|
||||
"github.com/cloudreve/Cloudreve/v3/pkg/thumb"
|
||||
testMock "github.com/stretchr/testify/mock"
|
||||
"testing"
|
||||
|
@ -126,22 +125,3 @@ func TestFileSystem_ThumbWorker(t *testing.T) {
|
|||
getThumbWorker().releaseWorker()
|
||||
})
|
||||
}
|
||||
|
||||
func TestFileSystem_GenerateThumbnail(t *testing.T) {
|
||||
fs := &FileSystem{User: &model.User{}}
|
||||
|
||||
// 无法生成缩略图
|
||||
{
|
||||
fs.SetTargetFile(&[]model.File{{}})
|
||||
fs.generateThumbnail(context.Background(), &model.File{})
|
||||
}
|
||||
|
||||
// 无法获取文件数据
|
||||
{
|
||||
testHandller := new(FileHeaderMock)
|
||||
testHandller.On("Get", testMock.Anything, "").Return(request.NopRSCloser{}, errors.New("error"))
|
||||
fs.Handler = testHandller
|
||||
fs.generateThumbnail(context.Background(), &model.File{Name: "test.png"})
|
||||
testHandller.AssertExpectations(t)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -27,3 +27,11 @@ func (c CacheClientMock) Sets(values map[string]interface{}, prefix string) erro
|
|||
func (c CacheClientMock) Delete(keys []string, prefix string) error {
|
||||
return c.Called(keys, prefix).Error(0)
|
||||
}
|
||||
|
||||
func (c CacheClientMock) Persist(path string) error {
|
||||
return c.Called(path).Error(0)
|
||||
}
|
||||
|
||||
func (c CacheClientMock) Restore(path string) error {
|
||||
return c.Called(path).Error(0)
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue