tstor/src/host/vfs/fs_test.go

44 lines
878 B
Go
Raw Normal View History

2023-10-16 09:18:40 +00:00
package vfs
2021-11-23 12:05:49 +00:00
import (
"io/fs"
"testing"
"github.com/stretchr/testify/require"
)
func TestFileinfo(t *testing.T) {
t.Parallel()
require := require.New(t)
2023-12-21 23:15:39 +00:00
fi := newFileInfo("abc/name", 42)
2021-11-23 12:05:49 +00:00
2023-12-21 23:15:39 +00:00
require.Equal("name", fi.Name())
require.False(fi.IsDir())
require.Equal(int64(42), fi.Size())
2021-11-23 12:05:49 +00:00
require.NotNil(fi.ModTime())
2023-12-21 23:15:39 +00:00
require.Zero(fi.Type() & fs.ModeDir)
require.Zero(fi.Mode() & fs.ModeDir)
require.Equal(fs.FileMode(0555), fi.Mode())
require.Equal(nil, fi.Sys())
}
func TestDirInfo(t *testing.T) {
t.Parallel()
require := require.New(t)
fi := newDirInfo("abc/name")
require.True(fi.IsDir())
require.Equal("name", fi.Name())
require.Equal(int64(0), fi.Size())
require.NotNil(fi.ModTime())
require.NotZero(fi.Type() & fs.ModeDir)
require.NotZero(fi.Mode() & fs.ModeDir)
require.Equal(defaultMode|fs.ModeDir, fi.Mode())
require.Equal(nil, fi.Sys())
2021-11-23 12:05:49 +00:00
}