Test: list folder & filesystem/path & model/folder/list

This commit is contained in:
HFO4
2019-11-24 16:28:41 +08:00
parent b431f3674c
commit 5e1e76719f
10 changed files with 255 additions and 7 deletions

View File

@ -2,7 +2,9 @@ package filesystem
import (
model "github.com/HFO4/cloudreve/models"
"github.com/gin-gonic/gin"
"github.com/stretchr/testify/assert"
"net/http/httptest"
"testing"
)
@ -23,3 +25,21 @@ func TestNewFileSystem(t *testing.T) {
fs, err = NewFileSystem(&user)
asserts.Error(err)
}
func TestNewFileSystemFromContext(t *testing.T) {
asserts := assert.New(t)
c, _ := gin.CreateTestContext(httptest.NewRecorder())
c.Set("user", &model.User{
Policy: model.Policy{
Type: "local",
},
})
fs, err := NewFileSystemFromContext(c)
asserts.NotNil(fs)
asserts.NoError(err)
c, _ = gin.CreateTestContext(httptest.NewRecorder())
fs, err = NewFileSystemFromContext(c)
asserts.Nil(fs)
asserts.Error(err)
}