touch: add support for touching files in directory, with options for recursive, filtering and dry-run/interactive

Fixes #5301
This commit is contained in:
albertony
2021-05-22 21:06:24 +02:00
parent 2e72ec96c1
commit 41876dd669
4 changed files with 132 additions and 48 deletions

View File

@@ -1573,3 +1573,22 @@ func TestCopyFileMaxTransfer(t *testing.T) {
fstest.CheckItems(t, r.Flocal, file1, file2, file3, file4)
fstest.CheckItems(t, r.Fremote, file1, file4)
}
func TestTouchDir(t *testing.T) {
ctx := context.Background()
r := fstest.NewRun(t)
defer r.Finalise()
file1 := r.WriteBoth(ctx, "potato2", "------------------------------------------------------------", t1)
file2 := r.WriteBoth(ctx, "empty space", "-", t2)
file3 := r.WriteBoth(ctx, "sub dir/potato3", "hello", t2)
fstest.CheckItems(t, r.Fremote, file1, file2, file3)
timeValue := time.Date(2010, 9, 8, 7, 6, 5, 4, time.UTC)
err := operations.TouchDir(ctx, r.Fremote, timeValue, true)
require.NoError(t, err)
file1.ModTime = timeValue
file2.ModTime = timeValue
file3.ModTime = timeValue
fstest.CheckItems(t, r.Fremote, file1, file2, file3)
}