aboutsummaryrefslogtreecommitdiff
path: root/lib/memfs/memfs_test.go
diff options
context:
space:
mode:
authorShulhan <ms@kilabit.info>2021-08-22 20:52:43 +0700
committerShulhan <ms@kilabit.info>2021-08-22 20:52:43 +0700
commitc1bd3574758c7070eb405922b56f0dfa056cad01 (patch)
tree0a041234bac4e1cadb82260dda519eb76d3d0fe0 /lib/memfs/memfs_test.go
parent884220a03acc6da626dd97f6f9682e5041e315e6 (diff)
downloadpakakeh.go-c1bd3574758c7070eb405922b56f0dfa056cad01.tar.xz
lib/memfs: fix empty file not being added to tree
Previously, we did not check if the file size is 0 before reading the content or updating the content type, which cause the read on file return io.EOF and the file not added to caches. This commit fix this issue by checking for zero file size and for io.EOF when reading the file content.
Diffstat (limited to 'lib/memfs/memfs_test.go')
-rw-r--r--lib/memfs/memfs_test.go8
1 files changed, 3 insertions, 5 deletions
diff --git a/lib/memfs/memfs_test.go b/lib/memfs/memfs_test.go
index 998913a3..18dc1eab 100644
--- a/lib/memfs/memfs_test.go
+++ b/lib/memfs/memfs_test.go
@@ -198,11 +198,9 @@ func TestMemFS_AddFile(t *testing.T) {
}
for _, c := range cases {
- t.Log(c.desc)
-
got, err := mfs.AddFile(c.intPath, c.extPath)
if err != nil {
- test.Assert(t, "error", c.expError, err.Error())
+ test.Assert(t, c.desc+": error", c.expError, err.Error())
continue
}
@@ -213,7 +211,7 @@ func TestMemFS_AddFile(t *testing.T) {
got.Childs = nil
}
- test.Assert(t, "AddFile", c.exp, got)
+ test.Assert(t, c.desc+": AddFile", c.exp, got)
if c.exp == nil {
continue
@@ -231,7 +229,7 @@ func TestMemFS_AddFile(t *testing.T) {
got.Childs = nil
}
- test.Assert(t, "Get", c.exp, got)
+ test.Assert(t, c.desc+": Get", c.exp, got)
}
}