summaryrefslogtreecommitdiff
path: root/tests/defaults/main_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'tests/defaults/main_test.go')
-rw-r--r--tests/defaults/main_test.go15
1 files changed, 15 insertions, 0 deletions
diff --git a/tests/defaults/main_test.go b/tests/defaults/main_test.go
index 52ca727..8c1b7e3 100644
--- a/tests/defaults/main_test.go
+++ b/tests/defaults/main_test.go
@@ -116,3 +116,18 @@ func TestOpenTruncateRead(t *testing.T) {
t.Fatalf("wrong content: %s", string(content))
}
}
+
+// TestWORead tries to read from a write-only file.
+func TestWORead(t *testing.T) {
+ fn := test_helpers.DefaultPlainDir + "/TestWORead"
+ fd, err := os.OpenFile(fn, os.O_CREATE|os.O_WRONLY, 0600)
+ if err != nil {
+ t.Fatal(err)
+ }
+ defer fd.Close()
+ buf := make([]byte, 10)
+ _, err = fd.Read(buf)
+ if err == nil {
+ t.Error("Reading from write-only file should fail, but did not")
+ }
+}