Test: download file in filesystem

This commit is contained in:
HFO4
2019-11-27 13:54:25 +08:00
parent 9bb432c220
commit 16067c3ac8
6 changed files with 138 additions and 5 deletions

View File

@@ -2,6 +2,7 @@ package filesystem
import (
model "github.com/HFO4/cloudreve/models"
"github.com/HFO4/cloudreve/pkg/filesystem/local"
"github.com/gin-gonic/gin"
"github.com/stretchr/testify/assert"
"net/http/httptest"
@@ -43,3 +44,22 @@ func TestNewFileSystemFromContext(t *testing.T) {
asserts.Nil(fs)
asserts.Error(err)
}
func TestDispatchHandler(t *testing.T) {
asserts := assert.New(t)
fs := &FileSystem{
User: &model.User{Policy: model.Policy{
Type: "local",
}},
}
// 未指定,使用用户默认
err := fs.dispatchHandler()
asserts.NoError(err)
asserts.IsType(local.Handler{}, fs.Handler)
// 已指定,发生错误
fs.Policy = &model.Policy{Type: "unknown"}
err = fs.dispatchHandler()
asserts.Error(err)
}