Commit 24adeab2 authored by Ivan Krasin's avatar Ivan Krasin

Unit test passes (early it just started Fuse connection and manual tests were required

parent e4f22131
...@@ -5,6 +5,7 @@ import ( ...@@ -5,6 +5,7 @@ import (
"log" "log"
"os" "os"
"path" "path"
"strings"
"testing" "testing"
"time" "time"
) )
...@@ -12,6 +13,9 @@ import ( ...@@ -12,6 +13,9 @@ import (
const ( const (
tempMountDir = "./.testMountDir" tempMountDir = "./.testMountDir"
) )
var (
testFileNames = []string { "one", "two", "three3" }
)
type testFuse struct{} type testFuse struct{}
...@@ -31,7 +35,7 @@ func (fs *testFuse) Lookup(parent, filename string) (out *Attr, code Error, err ...@@ -31,7 +35,7 @@ func (fs *testFuse) Lookup(parent, filename string) (out *Attr, code Error, err
} }
func (fs *testFuse) List(dir string) (names []string, code Error, err os.Error) { func (fs *testFuse) List(dir string) (names []string, code Error, err os.Error) {
names = []string { "a1", "b2", "caaaaa" } names = testFileNames
return return
} }
...@@ -63,9 +67,26 @@ func TestMount(t *testing.T) { ...@@ -63,9 +67,26 @@ func TestMount(t *testing.T) {
if err != nil { if err != nil {
t.Fatalf("Can't mount a dir, err: %v", err) t.Fatalf("Can't mount a dir, err: %v", err)
} }
errorHandler(errors) defer func() {
err = m.Unmount() err := m.Unmount()
if err != nil { if err != nil {
t.Fatalf("Can't unmount a dir, err: %v", err) t.Fatalf("Can't unmount a dir, err: %v", err)
} }
}()
go errorHandler(errors)
f, err := os.Open(tempMountDir, os.O_RDONLY, 0)
if err != nil {
t.Fatalf("Can't open a dir: %s, err: %v", tempMountDir, err)
}
defer f.Close()
names, err := f.Readdirnames(10)
if err != nil {
t.Fatalf("Can't ls a dir: %s, err: %v", tempMountDir, err)
}
has := strings.Join(names, ", ")
wanted := strings.Join(testFileNames, ", ")
if has != wanted {
t.Errorf("Ls returned wrong results, has: [%s], wanted: [%s]", has, wanted)
return
}
} }
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment