-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcache_test.go
41 lines (35 loc) · 1.03 KB
/
cache_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
package main
import (
"fmt"
"path/filepath"
"runtime"
"testing"
"github.com/stretchr/testify/assert"
)
func TestDefaultCache(t *testing.T) {
_, err := DefaultCache()
assert.NoError(t, err)
}
func TestIsHitMiss(t *testing.T) {
cache, err := DefaultCache()
assert.NoError(t, err)
hit := cache.IsHit("github.com/this-user-doesn't-exist/not-a-repository-that-exists")
assert.False(t, hit)
}
func TestCacheConfig(t *testing.T) {
_, filename, _, ok := runtime.Caller(0)
assert.Truef(t, ok, "failed to get filename of test file cache_test.go")
parent := filepath.Dir(filename)
testDataSlash := fmt.Sprintf("%s/testdata", parent)
cache := &Cache{filepath.FromSlash(testDataSlash)}
conf, err := cache.Config()
assert.NoError(t, err)
assert.Equal(t, conf.License, "GPLv3")
assert.Equal(t, conf.Name, "YourName/dotfiles")
}
func TestCleanDoesntExist(t *testing.T) {
invalidFile := "this-isn't-a-present-file-please-don't-let-this-be-a-present-file.abcdefgh"
cache := &Cache{invalidFile}
err := cache.Clean()
assert.NoError(t, err)
}