From 7f5d9a43f25a52e4d7ce628c17cd4084a98c68e5 Mon Sep 17 00:00:00 2001 From: Aaron Jacobs Date: Fri, 20 Mar 2015 11:54:09 +1100 Subject: [PATCH] FlushFSTest.CloseReports_ReadOnly --- samples/flushfs/flush_fs_test.go | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/samples/flushfs/flush_fs_test.go b/samples/flushfs/flush_fs_test.go index aec7f56..6dd73af 100644 --- a/samples/flushfs/flush_fs_test.go +++ b/samples/flushfs/flush_fs_test.go @@ -174,7 +174,30 @@ func (t *FlushFSTest) CloseReports_ReadWrite() { } func (t *FlushFSTest) CloseReports_ReadOnly() { - AssertTrue(false, "TODO") + var err error + + // Open the file. + f, err := os.OpenFile(path.Join(t.Dir, "foo"), os.O_RDONLY, 0) + AssertEq(nil, err) + + defer func() { + if f != nil { + ExpectEq(nil, f.Close()) + } + }() + + // At this point, no flushes or fsyncs should have happened. + AssertThat(t.getFlushes(), ElementsAre()) + AssertThat(t.getFsyncs(), ElementsAre()) + + // Close the file. + err = f.Close() + f = nil + AssertEq(nil, err) + + // Now we should have received the flush operation (but still no fsync). + ExpectThat(t.getFlushes(), ElementsAre(byteSliceEq(""))) + ExpectThat(t.getFsyncs(), ElementsAre()) } func (t *FlushFSTest) CloseReports_WriteOnly() {