From f6da4cc7f0c87a6ffb06cf0f491d6c0451fd071b Mon Sep 17 00:00:00 2001 From: HFO4 <912394456@qq.com> Date: Mon, 9 Dec 2019 12:18:30 +0800 Subject: [PATCH] Test: local handler.thumb --- pkg/filesystem/local/handller_test.go | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/pkg/filesystem/local/handller_test.go b/pkg/filesystem/local/handller_test.go index b5a0ab1..71da4ca 100644 --- a/pkg/filesystem/local/handller_test.go +++ b/pkg/filesystem/local/handller_test.go @@ -2,6 +2,7 @@ package local import ( "context" + "github.com/HFO4/cloudreve/pkg/conf" "github.com/HFO4/cloudreve/pkg/util" "github.com/stretchr/testify/assert" "io" @@ -89,3 +90,25 @@ func TestHandler_Get(t *testing.T) { asserts.Error(err) 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) + } +}