filebrowser/filemanager_test.go
Henrique Dias f40731d3b4 Use fileutils instead
Former-commit-id: 2688c5dca3865614edaf7b159b7f0dcebad77171 [formerly b919610fb1d09db5e6b6308e5adc0d431ce6c139] [formerly b7c60fcf5771ec9d1854947dd89dc51ff414bdb7 [formerly ff034f7e8f]]
Former-commit-id: a63a598c5cef6c050a8a0d189bc5235a98d5457a [formerly cab7076a63efddbfb968c151c5ef1d34b00dac56]
Former-commit-id: f167b30eeea3a9c0b8fec43dc37ee95cd8c172e6
2017-07-27 21:39:23 +01:00

50 lines
826 B
Go

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,
}
}