tstor/src/vfs/fs_test.go
royalcat 0ae11aa283
All checks were successful
docker / build-docker (push) Successful in 3m12s
correct modtime
2024-12-17 12:51:10 +03:00

44 lines
897 B
Go

package vfs
import (
"io/fs"
"testing"
"time"
"github.com/stretchr/testify/require"
)
func TestFileinfo(t *testing.T) {
t.Parallel()
require := require.New(t)
fi := NewFileInfo("abc/name", 42, time.Time{})
require.Equal("name", fi.Name())
require.False(fi.IsDir())
require.Equal(int64(42), fi.Size())
require.NotNil(fi.ModTime())
require.Zero(fi.Type() & fs.ModeDir)
require.Zero(fi.Mode() & fs.ModeDir)
require.Equal(fs.FileMode(0555), fi.Mode())
require.Nil(fi.Sys())
}
func TestDirInfo(t *testing.T) {
t.Parallel()
require := require.New(t)
fi := NewDirInfo("abc/name", time.Time{})
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(ModeFileRO|fs.ModeDir, fi.Mode())
require.Nil(fi.Sys())
}