aboutsummaryrefslogtreecommitdiff
path: root/lib/memfs/memfs_test.go
diff options
context:
space:
mode:
authorShulhan <ms@kilabit.info>2023-11-08 02:19:38 +0700
committerShulhan <ms@kilabit.info>2023-11-08 03:26:14 +0700
commit24be7f0256933fec01450fa01e4013dc0180880f (patch)
tree112ca7285d0a8c6d10d68d34bdd8118527757f09 /lib/memfs/memfs_test.go
parent5b327edb5a87929c74192d63fa6f0d7e160f3b88 (diff)
downloadpakakeh.go-24be7f0256933fec01450fa01e4013dc0180880f.tar.xz
lib/memfs: remove mocking os.Stat
The original idea of mocking the os.Stat to allow running test without adding Sleep, but this cause our tests a little bit flaky.
Diffstat (limited to 'lib/memfs/memfs_test.go')
-rw-r--r--lib/memfs/memfs_test.go31
1 files changed, 0 insertions, 31 deletions
diff --git a/lib/memfs/memfs_test.go b/lib/memfs/memfs_test.go
index 7e210d9e..15aebf9b 100644
--- a/lib/memfs/memfs_test.go
+++ b/lib/memfs/memfs_test.go
@@ -10,7 +10,6 @@ import (
"log"
"os"
"path/filepath"
- "sync/atomic"
"testing"
"time"
@@ -19,36 +18,9 @@ import (
)
var (
- _epoch atomic.Int64
_testWD string
)
-// mockOsStat mock the os.Stat by returning FileInfo with mocked ModTime that
-// always increased 1 second every call.
-func mockOsStat(path string) (fi os.FileInfo, err error) {
- var orgfi os.FileInfo
-
- orgfi, err = os.Stat(path)
- if err != nil {
- return nil, err
- }
-
- var node = &Node{
- name: orgfi.Name(),
- size: orgfi.Size(),
- mode: orgfi.Mode(),
- modTime: time.Unix(_epoch.Load(), 0),
- }
- if !orgfi.IsDir() {
- node.Content, err = os.ReadFile(path)
- if err != nil {
- return nil, err
- }
- }
- _epoch.Add(1)
- return node, nil
-}
-
func TestMain(m *testing.M) {
var err error
@@ -79,9 +51,6 @@ func TestMain(m *testing.M) {
}
}
- _epoch.Store(1684424377)
- osStat = mockOsStat
-
os.Exit(m.Run())
}