-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathimagine_test.go
43 lines (33 loc) · 858 Bytes
/
imagine_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
42
43
package imagine
import (
"context"
"os"
"testing"
"github.com/stretchr/testify/assert"
)
func TestImageineMap(t *testing.T) {
ctx := context.Background()
testDataDir := "./test/"
os.Mkdir(testDataDir, 0755)
baseName := testDataDir + "longtest." + string(genRandomBytes(6))
dbfile := baseName + ".dm"
indexfile := baseName + ".dmx"
dmfile := baseName + ".dmb"
pagesize := 128
dmopt, err := BuildDiskMapOpt(dbfile, indexfile, dmfile, pagesize, DecodeBytesValue)
assert.Nil(t, err)
opt := ImagineOption{
MemMapOpt: MemMapOpt{ValueFunc: DecodeBytesValue},
DiskMapOpt: dmopt,
}
im, err := NewImagineMap(opt)
assert.Nil(t, err)
assert.NotNil(t, im)
defer im.Close(ctx)
normalMapTest(ctx, normalMapOpt{
PageSize: pagesize, Map: im,
IdxFilePath: indexfile,
DataFilePath: dbfile,
WithCloseAndOpen: false,
}, t)
}