From fa887417708484eee03daf423a96d024960ed524 Mon Sep 17 00:00:00 2001 From: Jakob Unterwurzacher Date: Sun, 4 Oct 2015 10:38:58 +0200 Subject: [PATCH] tests: add TestFileHoles Create a file with holes by writing to offset 0 (block #0) and offset 4096 (block #1). This test currently fails. --- main_test.go | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/main_test.go b/main_test.go index 4f51d00..dba3ef1 100644 --- a/main_test.go +++ b/main_test.go @@ -178,6 +178,23 @@ func TestAppend(t *testing.T) { } } +// Create a file with holes by writing to offset 0 (block #0) and +// offset 4096 (block #1). +func TestFileHoles(t *testing.T) { + fn := plainDir + "fileholes" + file, err := os.Create(fn) + if err != nil { + t.Errorf("file create failed") + } + foo := []byte("foo") + file.Write(foo) + file.WriteAt(foo, 4096) + _, err = ioutil.ReadFile(fn) + if err != nil { + t.Error(err) + } +} + func BenchmarkStreamWrite(t *testing.B) { buf := make([]byte, 1024*1024) t.SetBytes(int64(len(buf)))