Skip to content

Commit 293ac91

Browse files
committed
chore: bug test
Add a standalone test for the os.ReadDir issue.
1 parent ca7dd3a commit 293ac91

1 file changed

Lines changed: 14 additions & 1 deletion

File tree

pkg/gopro/osfs_test.go

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,19 @@ import (
1010
"github.com/stretchr/testify/require"
1111
)
1212

13+
func Test_ReadDir(t *testing.T) {
14+
tf, err := os.CreateTemp(t.TempDir(), "os-test")
15+
require.NoError(t, err)
16+
17+
name := tf.Name()
18+
require.NoError(t, tf.Close())
19+
20+
dirs, err := os.ReadDir(name)
21+
require.ErrorIs(t, err, syscall.ENOTDIR)
22+
var expectedDirs []fs.DirEntry
23+
require.Equal(t, expectedDirs, dirs)
24+
}
25+
1326
func TestOSFS(t *testing.T) {
1427
o := osFS{}
1528
tf, err := o.CreateTemp("", "gopro-test")
@@ -18,7 +31,7 @@ func TestOSFS(t *testing.T) {
1831

1932
name := tf.Name()
2033

21-
defer os.Remove(name) //nolint: errcheck
34+
t.Cleanup(func() { require.NoError(t, os.Remove(name)) })
2235

2336
now := time.Now().Round(0)
2437
err = o.Chtimes(name, now, now)

0 commit comments

Comments
 (0)