| 1 | |
| 2 | |
| 3 | |
| 4 | package sftp |
| 5 | |
| 6 | import ( |
| 7 | "os" |
| 8 | "path/filepath" |
| 9 | "testing" |
| 10 | "time" |
| 11 | |
| 12 | "github.com/stretchr/testify/assert" |
| 13 | "github.com/stretchr/testify/require" |
| 14 | ) |
| 15 | |
| 16 | func TestFileStatFromInfoAtime(t *testing.T) { |
| 17 | f := filepath.Join(t.TempDir(), "f") |
| 18 | require.NoError(t, os.WriteFile(f, nil, 0o644)) |
| 19 | at, mt := time.Unix(1000000000, 0), time.Unix(1500000000, 0) |
| 20 | require.NoError(t, os.Chtimes(f, at, mt)) |
| 21 | fi, err := os.Stat(f) |
| 22 | require.NoError(t, err) |
| 23 | _, st := fileStatFromInfo(fi) |
| 24 | assert.Equal(t, uint32(at.Unix()), st.Atime) |
| 25 | assert.Equal(t, uint32(mt.Unix()), st.Mtime) |
| 26 | } |