mirror of
https://github.com/filebrowser/filebrowser.git
synced 2024-06-07 23:00:43 +00:00
4b602be5e3
Former-commit-id: 54b88552d11f2151a165dba9debb4657dfa56cf8 [formerly 0ce53651a8e9660f9d5f977295f553b5b1d1e93a] [formerly 7ebca3a8896222091c95af86a9cf1d12550b8b76 [formerly 174330929a
]]
Former-commit-id: 993d0cdb239f9969587d13a11ee8469fa8b91287 [formerly c22c911f944dd8d6597ab95589842d3c68d34869]
Former-commit-id: 44ed259fe50a085e8bcace3f1f14caafec97ce66
50 lines
826 B
Plaintext
50 lines
826 B
Plaintext
package filemanager
|
|
|
|
import (
|
|
"io/ioutil"
|
|
"os"
|
|
"path/filepath"
|
|
"testing"
|
|
|
|
"github.com/hacdias/fileutils"
|
|
)
|
|
|
|
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 = fileutils.CopyDir("./testdata", scope)
|
|
if err != nil {
|
|
t.Fatalf("Error copying the test data: %v", err)
|
|
}
|
|
|
|
user := DefaultUser
|
|
user.FileSystem = fileutils.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,
|
|
}
|
|
}
|