From 45795d4717589cdd1c0c0cdf7bb14e86c44e84ee Mon Sep 17 00:00:00 2001 From: Aaron Jacobs Date: Mon, 29 Feb 2016 02:34:31 +0000 Subject: [PATCH] TestSuccessfulMount --- mount_test.go | 61 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100644 mount_test.go diff --git a/mount_test.go b/mount_test.go new file mode 100644 index 0000000..590125e --- /dev/null +++ b/mount_test.go @@ -0,0 +1,61 @@ +package fuse_test + +import ( + "io/ioutil" + "os" + "testing" + + "golang.org/x/net/context" + + "github.com/jacobsa/fuse" + "github.com/jacobsa/fuse/fuseutil" +) + +//////////////////////////////////////////////////////////////////////// +// minimalFS +//////////////////////////////////////////////////////////////////////// + +// A minimal fuseutil.FileSystem that can successfully mount but do nothing +// else. +type minimalFS struct { + fuseutil.NotImplementedFileSystem +} + +//////////////////////////////////////////////////////////////////////// +// Tests +//////////////////////////////////////////////////////////////////////// + +func TestSuccessfulMount(t *testing.T) { + ctx := context.Background() + + // Set up a temporary directory. + dir, err := ioutil.TempDir("", "mount_test") + if err != nil { + t.Fatal("ioutil.TempDir: %v", err) + } + + defer os.RemoveAll(dir) + + // Mount. + fs := &minimalFS{} + mfs, err := fuse.Mount( + dir, + fuseutil.NewFileSystemServer(fs), + &fuse.MountConfig{}) + + if err != nil { + t.Fatalf("fuse.Mount: %v", err) + } + + defer func() { + if err := mfs.Join(ctx); err != nil { + t.Errorf("Joining: %v", err) + } + }() + + defer fuse.Unmount(mfs.Dir()) +} + +func TestNonEmptyMountPoint(t *testing.T) { + t.Fatal("TODO") +}