]> git.lizzy.rs Git - go-fscache.git/blobdiff - cachestat_test.go
Replace obsolete lock package
[go-fscache.git] / cachestat_test.go
index 735072c536ee9a33aa6613467f5b3c6cfef3289d..087e5dc0fb877ff52fec2ddfbc8e9968d6f6794e 100755 (executable)
@@ -1,7 +1,7 @@
 package fscache_test
 
 import (
-       "github.com/Kovensky/go-fscache"
+       "github.com/EliasFleckenstein03/go-fscache"
        "math/rand"
        "testing"
        "time"
@@ -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)
+       }
+}