]> git.lizzy.rs Git - go-fscache.git/blob - cachegob_test.go
Replace obsolete lock package
[go-fscache.git] / cachegob_test.go
1 package fscache_test
2
3 import (
4         "github.com/EliasFleckenstein03/go-fscache"
5         "math/rand"
6         "testing"
7         "time"
8 )
9
10 func init() {
11         rand.Seed(time.Now().UnixNano())
12 }
13
14 func TestCache_Set(T *testing.T) {
15         cd, err := fscache.NewCacheDir(".testdir")
16         if err != nil {
17                 T.Fatal(err)
18                 return
19         }
20
21         val := rand.Int63()
22         val2 := ^val // make it different
23
24         _, err = cd.Set(val, "test", "set")
25         if err != nil {
26                 T.Fatal(err)
27                 return
28         }
29
30         _, err = cd.Get(&val2, "test", "set")
31         if err != nil {
32                 T.Fatal(err)
33                 return
34         }
35
36         if val != val2 {
37                 T.Errorf("Expected %d, got %d", val, val2)
38         }
39 }