1
0
Fork 0
mirror of https://github.com/restic/restic.git synced 2025-03-30 00:00:14 +01:00
restic/internal/fs/stat_test.go
greatroar e2886ba495 fs: Reimplement Stat/Lstat on Linux using statx
This gives us access to additional information, notably the birth time
of files on btrfs.
2024-10-27 10:40:12 +01:00

31 lines
555 B
Go

//go:build !linux
package fs
import (
"os"
"path/filepath"
"testing"
rtest "github.com/restic/restic/internal/test"
)
func TestExtendedStat(t *testing.T) {
tempdir := rtest.TempDir(t)
filename := filepath.Join(tempdir, "file")
err := os.WriteFile(filename, []byte("foobar"), 0640)
if err != nil {
t.Fatal(err)
}
fi, err := Lstat(filename)
if err != nil {
t.Fatal(err)
}
extFI := ExtendedStat(fi)
if !extFI.ModTime.Equal(fi.ModTime()) {
t.Errorf("extFI.ModTime does not match, want %v, got %v", fi.ModTime(), extFI.ModTime)
}
}