tstor/src/vfs/fs_test.go

45 lines
897 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"
2024-12-17 09:51:10 +00:00
"time"
2021-11-23 12:05:49 +00:00
"github.com/stretchr/testify/require"
)
func TestFileinfo(t *testing.T) {
t.Parallel()
require := require.New(t)
2024-12-17 09:51:10 +00:00
fi := NewFileInfo("abc/name", 42, time.Time{})
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())
2024-03-17 21:00:34 +00:00
require.Nil(fi.Sys())
2023-12-21 23:15:39 +00:00
}
func TestDirInfo(t *testing.T) {
t.Parallel()
require := require.New(t)
2024-12-17 09:51:10 +00:00
fi := NewDirInfo("abc/name", time.Time{})
2023-12-21 23:15:39 +00:00
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)
2024-11-15 13:39:56 +00:00
require.Equal(ModeFileRO|fs.ModeDir, fi.Mode())
2024-03-17 21:00:34 +00:00
require.Nil(fi.Sys())
2021-11-23 12:05:49 +00:00
}