diff --git a/samples/flushfs/flush_fs_test.go b/samples/flushfs/flush_fs_test.go index 290630e..ce155d7 100644 --- a/samples/flushfs/flush_fs_test.go +++ b/samples/flushfs/flush_fs_test.go @@ -21,6 +21,7 @@ import ( "sync" "testing" + "github.com/jacobsa/fuse" "github.com/jacobsa/fuse/samples" "github.com/jacobsa/fuse/samples/flushfs" . "github.com/jacobsa/oglematchers" @@ -103,6 +104,22 @@ func (t *FlushFSTest) getFsyncs() (p []string) { return } +// LOCKS_EXCLUDED(t.mu) +func (t *FlushFSTest) setFlushError(err error) { + t.mu.Lock() + defer t.mu.Unlock() + + t.flushErr = err +} + +// LOCKS_EXCLUDED(t.mu) +func (t *FlushFSTest) setFsyncError(err error) { + t.mu.Lock() + defer t.mu.Unlock() + + t.fsyncErr = err +} + //////////////////////////////////////////////////////////////////////// // Tests //////////////////////////////////////////////////////////////////////// @@ -324,7 +341,25 @@ func (t *FlushFSTest) CloseReports_MultipleTimes_OverlappingFileHandles() { } func (t *FlushFSTest) CloseError() { - AssertTrue(false, "TODO") + // Open a file. + f, err := os.OpenFile(path.Join(t.Dir, "foo"), os.O_RDWR, 0) + AssertEq(nil, err) + + defer func() { + if f != nil { + ExpectEq(nil, f.Close()) + } + }() + + // Configure a flush error. + t.setFlushError(fuse.ENOENT) + + // Close the file. + err = f.Close() + f = nil + + AssertNe(nil, err) + ExpectThat(err, Error(HasSubstr("TODO"))) } func (t *FlushFSTest) FsyncReports() {