2018-01-03 20:53:45 +00:00
|
|
|
package fs
|
|
|
|
|
|
|
|
import (
|
2022-12-02 18:36:43 +00:00
|
|
|
"os"
|
2018-01-03 20:53:45 +00:00
|
|
|
"path/filepath"
|
|
|
|
"testing"
|
|
|
|
|
|
|
|
restictest "github.com/restic/restic/internal/test"
|
|
|
|
)
|
|
|
|
|
|
|
|
func TestExtendedStat(t *testing.T) {
|
2022-12-09 12:42:33 +00:00
|
|
|
tempdir := restictest.TempDir(t)
|
2018-01-03 20:53:45 +00:00
|
|
|
filename := filepath.Join(tempdir, "file")
|
2022-12-02 18:36:43 +00:00
|
|
|
err := os.WriteFile(filename, []byte("foobar"), 0640)
|
2018-01-03 20:53:45 +00:00
|
|
|
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)
|
|
|
|
}
|
|
|
|
}
|