(t *testing.T)
| 660 | } |
| 661 | |
| 662 | func TestDirEntryModTimeInvalidation(t *testing.T) { |
| 663 | r, vfs := newTestVFS(t) |
| 664 | features := r.Fremote.Features() |
| 665 | if !features.DirModTimeUpdatesOnWrite { |
| 666 | t.Skip("Need DirModTimeUpdatesOnWrite") |
| 667 | } |
| 668 | if features.IsLocal && runtime.GOOS == "windows" { |
| 669 | t.Skip("dirent modtime is unreliable on Windows filesystems") |
| 670 | } |
| 671 | |
| 672 | r.WriteObject(context.Background(), "dir/file1", "file1 contents", t1) |
| 673 | |
| 674 | // Read the modtime of the directory fresh |
| 675 | vfs.FlushDirCache() |
| 676 | node, err := vfs.Stat("dir") |
| 677 | require.NoError(t, err) |
| 678 | modTime1 := node.(*Dir).DirEntry().ModTime(context.Background()) |
| 679 | |
| 680 | // Wait some time (we wait for Precision+10%), then write another file |
| 681 | // which should update the ModTime of the directory. |
| 682 | prec := (11 * vfs.f.Precision()) / 10 |
| 683 | time.Sleep(max(100*time.Millisecond, prec)) |
| 684 | r.WriteObject(context.Background(), "dir/file2", "file2 contents", t2) |
| 685 | |
| 686 | // Read the modtime of the directory fresh again - it should have changed |
| 687 | vfs.FlushDirCache() |
| 688 | node2, err := vfs.Stat("dir") |
| 689 | require.NoError(t, err) |
| 690 | modTime2 := node2.(*Dir).DirEntry().ModTime(context.Background()) |
| 691 | |
| 692 | // ModTime of directory must be different after second file was written. |
| 693 | if modTime1.Equal(modTime2) { |
| 694 | t.Error("ModTime not invalidated") |
| 695 | } |
| 696 | } |
| 697 | |
| 698 | func TestDirMetadataExtension(t *testing.T) { |
| 699 | r, vfs, dir, _ := dirCreate(t) |
nothing calls this directly
no test coverage detected
searching dependent graphs…