Test: local handler.thumb

This commit is contained in:
HFO4 2019-12-09 12:18:30 +08:00
parent c3c0e92964
commit f6da4cc7f0

View file

@ -2,6 +2,7 @@ package local
import ( import (
"context" "context"
"github.com/HFO4/cloudreve/pkg/conf"
"github.com/HFO4/cloudreve/pkg/util" "github.com/HFO4/cloudreve/pkg/util"
"github.com/stretchr/testify/assert" "github.com/stretchr/testify/assert"
"io" "io"
@ -89,3 +90,25 @@ func TestHandler_Get(t *testing.T) {
asserts.Error(err) asserts.Error(err)
asserts.Nil(rs) asserts.Nil(rs)
} }
func TestHandler_Thumb(t *testing.T) {
asserts := assert.New(t)
handler := Handler{}
ctx := context.Background()
file, err := os.Create("TestHandler_Thumb" + conf.ThumbConfig.FileSuffix)
asserts.NoError(err)
file.Close()
// 正常
{
thumb, err := handler.Thumb(ctx, "TestHandler_Thumb")
asserts.NoError(err)
asserts.NotNil(thumb.Content)
}
// 不存在
{
_, err := handler.Thumb(ctx, "not_exist")
asserts.Error(err)
}
}