From: Diogo Franco (Kovensky) Date: Wed, 17 Jul 2013 03:16:38 +0000 (-0300) Subject: Add (*CacheDir).Chtime test X-Git-Tag: v0.0.1~1 X-Git-Url: https://git.lizzy.rs/?a=commitdiff_plain;h=c3cf6b75935f1a8b7119c6734386214b44e6da34;p=go-fscache.git Add (*CacheDir).Chtime test --- diff --git a/cachestat_test.go b/cachestat_test.go index 735072c..252af6e 100755 --- a/cachestat_test.go +++ b/cachestat_test.go @@ -95,3 +95,41 @@ func TestCache_Touch(T *testing.T) { T.Errorf("Touch did not update timestamp (FAT filesystem?)") } } + +func TestCache_Chtime(T *testing.T) { + cd, err := fscache.NewCacheDir(".testdir") + if err != nil { + T.Fatal(err) + return + } + + err = cd.Touch("test", "chtime") + if err != nil { + T.Fatal(err) + return + } + + stat, err := cd.Stat("test", "chtime") + if err != nil { + T.Fatal(err) + return + } + + newTime := stat.ModTime().Add(-1 * 7 * 24 * time.Hour) + + err = cd.Chtime(newTime, "test", "chtime") + if err != nil { + T.Fatal(err) + return + } + + stat, err = cd.Stat("test", "chtime") + if err != nil { + T.Fatal(err) + return + } + + if mtime := stat.ModTime(); !mtime.Equal(newTime) { + T.Errorf("Expected mtime %q, got mtime %q", newTime, mtime) + } +}