forked from wal-g/wal-g
-
Notifications
You must be signed in to change notification settings - Fork 0
/
prefetch_test.go
40 lines (33 loc) · 1.23 KB
/
prefetch_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
package test
import (
"github.com/stretchr/testify/assert"
"github.com/wal-g/wal-g/internal"
"testing"
)
type MockCleaner struct {
deleted []string
}
func (cl *MockCleaner) GetFiles(directory string) (files []string, err error) {
files = []string{
"000000010000000100000056",
"000000010000000100000057",
"000000010000000100000058",
"000000010000000100000059",
"00000001000000010000005A",
}
return
}
func (cl *MockCleaner) Remove(file string) {
cl.deleted = append(cl.deleted, file)
}
func TestCleanup(t *testing.T) {
cleaner := MockCleaner{}
internal.CleanupPrefetchDirectories("000000010000000100000058", "/A", &cleaner)
assert.NotContains(t, cleaner.deleted, "/A/.wal-g/prefetch/000000010000000100000058")
assert.NotContains(t, cleaner.deleted, "/A/.wal-g/prefetch/running/000000010000000100000059")
assert.NotContains(t, cleaner.deleted, "/A/.wal-g/prefetch/00000001000000010000005A")
assert.Contains(t, cleaner.deleted, "/A/.wal-g/prefetch/000000010000000100000056")
assert.Contains(t, cleaner.deleted, "/A/.wal-g/prefetch/000000010000000100000056")
assert.Contains(t, cleaner.deleted, "/A/.wal-g/prefetch/000000010000000100000056")
assert.Contains(t, cleaner.deleted, "/A/.wal-g/prefetch/000000010000000100000056")
}