-
Notifications
You must be signed in to change notification settings - Fork 0
/
gcinterval_test.go
33 lines (23 loc) · 797 Bytes
/
gcinterval_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
package filecache
import (
"testing"
"time"
"github.com/stretchr/testify/assert"
)
func TestIntervalGarbageCollector(t *testing.T) {
prepareGCTestFiles(t)
gc := NewIntervalGarbageCollector("./testdata/gc", 50*time.Millisecond)
gc.OnInstanceInit()
gc.OnOperation()
assert.FileExists(t, "./testdata/gc/test1.cache")
assert.FileExists(t, "./testdata/gc/test1.cache--meta")
assert.FileExists(t, "./testdata/gc/test2.cache")
assert.FileExists(t, "./testdata/gc/test2.cache--meta")
time.Sleep(55 * time.Millisecond)
assert.NoFileExists(t, "./testdata/gc/test1.cache")
assert.NoFileExists(t, "./testdata/gc/test1.cache--meta")
assert.FileExists(t, "./testdata/gc/test2.cache")
assert.FileExists(t, "./testdata/gc/test2.cache--meta")
err := gc.Close()
assert.NoError(t, err)
}