@@ -11,7 +11,13 @@ exports.all = function (test, testCommon) {
11
11
const db = testCommon . factory ( )
12
12
await db . open ( )
13
13
await db . put ( 'test' , testBuffer ( ) , { valueEncoding : 'buffer' } )
14
+
14
15
t . same ( await db . get ( 'test' , { valueEncoding : 'buffer' } ) , testBuffer ( ) )
16
+
17
+ if ( testCommon . supports . getSync ) {
18
+ t . same ( db . getSync ( 'test' , { valueEncoding : 'buffer' } ) , testBuffer ( ) , 'sync' )
19
+ }
20
+
15
21
return db . close ( )
16
22
} )
17
23
@@ -20,7 +26,13 @@ exports.all = function (test, testCommon) {
20
26
const db = testCommon . factory ( { valueEncoding : 'buffer' } )
21
27
await db . open ( )
22
28
await db . put ( 'test' , testBuffer ( ) )
29
+
23
30
t . same ( await db . get ( 'test' ) , testBuffer ( ) )
31
+
32
+ if ( testCommon . supports . getSync ) {
33
+ t . same ( db . getSync ( 'test' ) , testBuffer ( ) , 'sync' )
34
+ }
35
+
24
36
return db . close ( )
25
37
} )
26
38
@@ -29,7 +41,13 @@ exports.all = function (test, testCommon) {
29
41
const db = testCommon . factory ( )
30
42
await db . open ( )
31
43
await db . put ( testBuffer ( ) , 'test' , { keyEncoding : 'buffer' } )
44
+
32
45
t . same ( await db . get ( testBuffer ( ) , { keyEncoding : 'buffer' } ) , 'test' )
46
+
47
+ if ( testCommon . supports . getSync ) {
48
+ t . same ( db . getSync ( testBuffer ( ) , { keyEncoding : 'buffer' } ) , 'test' , 'sync' )
49
+ }
50
+
33
51
return db . close ( )
34
52
} )
35
53
@@ -38,7 +56,13 @@ exports.all = function (test, testCommon) {
38
56
const db = testCommon . factory ( )
39
57
await db . open ( )
40
58
await db . put ( Buffer . from ( 'foo🐄' ) , 'test' , { keyEncoding : 'utf8' } )
59
+
41
60
t . same ( await db . get ( Buffer . from ( 'foo🐄' ) , { keyEncoding : 'utf8' } ) , 'test' )
61
+
62
+ if ( testCommon . supports . getSync ) {
63
+ t . same ( db . getSync ( Buffer . from ( 'foo🐄' ) , { keyEncoding : 'utf8' } ) , 'test' , 'sync' )
64
+ }
65
+
42
66
return db . close ( )
43
67
} )
44
68
@@ -47,8 +71,15 @@ exports.all = function (test, testCommon) {
47
71
const db = testCommon . factory ( )
48
72
await db . open ( )
49
73
await db . put ( 'test' , 'foo🐄' , { valueEncoding : 'buffer' } )
74
+
50
75
t . same ( await db . get ( 'test' , { valueEncoding : 'buffer' } ) , Buffer . from ( 'foo🐄' ) )
51
76
t . same ( await db . get ( 'test' , { valueEncoding : 'utf8' } ) , 'foo🐄' )
77
+
78
+ if ( testCommon . supports . getSync ) {
79
+ t . same ( db . getSync ( 'test' , { valueEncoding : 'buffer' } ) , Buffer . from ( 'foo🐄' ) , 'sync' )
80
+ t . same ( db . getSync ( 'test' , { valueEncoding : 'utf8' } ) , 'foo🐄' , 'sync' )
81
+ }
82
+
52
83
return db . close ( )
53
84
} )
54
85
@@ -62,11 +93,19 @@ exports.all = function (test, testCommon) {
62
93
const promise1 = db . put ( a , a ) . then ( async ( ) => {
63
94
const value = await db . get ( Buffer . from ( a ) , enc )
64
95
t . same ( value , Buffer . from ( a ) , 'got buffer value' )
96
+
97
+ if ( testCommon . supports . getSync ) {
98
+ t . same ( db . getSync ( Buffer . from ( a ) , enc ) , Buffer . from ( a ) , 'got buffer value (sync)' )
99
+ }
65
100
} )
66
101
67
102
const promise2 = db . put ( Buffer . from ( b ) , Buffer . from ( b ) , enc ) . then ( async ( ) => {
68
103
const value = await db . get ( b )
69
104
t . same ( value , b , 'got string value' )
105
+
106
+ if ( testCommon . supports . getSync ) {
107
+ t . same ( db . getSync ( b ) , b , 'got string value (sync)' )
108
+ }
70
109
} )
71
110
72
111
await Promise . all ( [ promise1 , promise2 ] )
0 commit comments