mirror of
https://github.com/halejohn/Cloudreve.git
synced 2026-01-28 10:51:57 +08:00
Test: download file in filesystem
This commit is contained in:
@@ -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)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user