mirror of
https://github.com/cloudreve/cloudreve.git
synced 2025-11-01 10:36:30 +08:00
Test: list folder & filesystem/path & model/folder/list
This commit is contained in:
@ -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)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user