-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathverify_test.go
84 lines (67 loc) · 2.12 KB
/
verify_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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
package rdb
import (
"os"
"path/filepath"
"testing"
"github.com/stretchr/testify/require"
)
var allTypesRDBPath = filepath.Join(dumpsPath, "all-types.rdb")
var streamWithPELRDBPath = filepath.Join(dumpsPath, "stream-with-pel.rdb")
var stringRDBValuePath = filepath.Join(valueDumpsPath, "string.bin")
var streamWithPELRDBValuePath = filepath.Join(valueDumpsPath, "stream-listpacks3.bin")
func TestVerifyFile(t *testing.T) {
err := VerifyFile(allTypesRDBPath, VerifyFileOptions{})
require.NoError(t, err)
err = VerifyFile(streamWithPELRDBPath, VerifyFileOptions{})
require.NoError(t, err)
}
func TestVerifyFile_maxDataSize(t *testing.T) {
err := VerifyFile(allTypesRDBPath, VerifyFileOptions{
MaxDataSize: 10,
})
require.ErrorContains(t, err, "max data size")
}
func TestVerifyFile_maxEntrySize(t *testing.T) {
err := VerifyFile(allTypesRDBPath, VerifyFileOptions{
MaxEntrySize: 5,
})
require.ErrorContains(t, err, "max entry size")
}
func TestVerifyFile_maxKeySize(t *testing.T) {
err := VerifyFile(allTypesRDBPath, VerifyFileOptions{
MaxKeySize: 1,
})
require.ErrorContains(t, err, "max key size")
}
func TestVerifyFile_maxStreamPELSize(t *testing.T) {
err := VerifyFile(streamWithPELRDBPath, VerifyFileOptions{
MaxStreamPELSize: 1,
})
require.ErrorContains(t, err, "max stream pel size")
}
func TestVerifyValue(t *testing.T) {
dump, err := os.ReadFile(stringRDBValuePath)
require.NoError(t, err)
err = VerifyValue(dump, VerifyValueOptions{})
require.NoError(t, err)
dump, err = os.ReadFile(streamWithPELRDBValuePath)
require.NoError(t, err)
err = VerifyValue(dump, VerifyValueOptions{})
require.NoError(t, err)
}
func TestVerifyValue_maxEntrySize(t *testing.T) {
dump, err := os.ReadFile(stringRDBValuePath)
require.NoError(t, err)
err = VerifyValue(dump, VerifyValueOptions{
MaxEntrySize: 12,
})
require.ErrorContains(t, err, "max entry size")
}
func TestVerifyValue_maxStreamPELSize(t *testing.T) {
dump, err := os.ReadFile(streamWithPELRDBValuePath)
require.NoError(t, err)
err = VerifyValue(dump, VerifyValueOptions{
MaxStreamPELSize: 1,
})
require.ErrorContains(t, err, "max stream pel size")
}