You've already forked filebrowser
mirror of
https://github.com/filebrowser/filebrowser.git
synced 2025-11-26 14:25:26 +08:00
Add some auth tests
This commit is contained in:
49
filemanager_test.go
Normal file
49
filemanager_test.go
Normal file
@@ -0,0 +1,49 @@
|
||||
package filemanager
|
||||
|
||||
import (
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"testing"
|
||||
|
||||
"golang.org/x/net/webdav"
|
||||
)
|
||||
|
||||
type test struct {
|
||||
*FileManager
|
||||
Temp string
|
||||
}
|
||||
|
||||
func (t test) Clean() {
|
||||
t.db.Close()
|
||||
os.RemoveAll(t.Temp)
|
||||
}
|
||||
|
||||
func newTest(t *testing.T) *test {
|
||||
temp, err := ioutil.TempDir("", t.Name())
|
||||
if err != nil {
|
||||
t.Fatalf("Error creating temporary directory: %v", err)
|
||||
}
|
||||
|
||||
scope := filepath.Join(temp, "scope")
|
||||
database := filepath.Join(temp, "database.db")
|
||||
|
||||
err = copyDir("./testdata", scope)
|
||||
if err != nil {
|
||||
t.Fatalf("Error copying the test data: %v", err)
|
||||
}
|
||||
|
||||
user := DefaultUser
|
||||
user.FileSystem = webdav.Dir(scope)
|
||||
|
||||
fm, err := New(database, user)
|
||||
|
||||
if err != nil {
|
||||
t.Fatalf("Error creating a file manager instance: %v", err)
|
||||
}
|
||||
|
||||
return &test{
|
||||
FileManager: fm,
|
||||
Temp: temp,
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user