@@ -30,6 +30,64 @@ describe('open/close', function() {
30
30
helper . deleteFile ( 'test/tmp/test_create.db' ) ;
31
31
} ) ;
32
32
} ) ;
33
+
34
+ describe ( 'open and close non-existant shared database' , function ( ) {
35
+ before ( function ( ) {
36
+ helper . deleteFile ( 'test/tmp/test_create_shared.db' ) ;
37
+ } ) ;
38
+
39
+ var db ;
40
+ it ( 'should open the database' , function ( done ) {
41
+ db = new sqlite3 . Database ( 'file:./test/tmp/test_create_shared.db' , sqlite3 . OPEN_URI | sqlite3 . OPEN_SHAREDCACHE | sqlite3 . OPEN_READWRITE | sqlite3 . OPEN_CREATE , done ) ;
42
+ } ) ;
43
+
44
+ it ( 'should close the database' , function ( done ) {
45
+ db . close ( done ) ;
46
+ } ) ;
47
+
48
+ it ( 'should have created the file' , function ( ) {
49
+ assert . fileExists ( 'test/tmp/test_create_shared.db' ) ;
50
+ } ) ;
51
+
52
+ after ( function ( ) {
53
+ helper . deleteFile ( 'test/tmp/test_create_shared.db' ) ;
54
+ } ) ;
55
+ } ) ;
56
+
57
+
58
+ ( sqlite3 . VERSION_NUMBER < 3008000 ? describe . skip : describe ) ( 'open and close shared memory database' , function ( ) {
59
+
60
+ var db1 ;
61
+ var db2 ;
62
+
63
+ it ( 'should open the first database' , function ( done ) {
64
+ db1 = new sqlite3 . Database ( 'file:./test/tmp/test_memory.db?mode=memory' , sqlite3 . OPEN_URI | sqlite3 . OPEN_SHAREDCACHE | sqlite3 . OPEN_READWRITE | sqlite3 . OPEN_CREATE , done ) ;
65
+ } ) ;
66
+
67
+ it ( 'should open the second database' , function ( done ) {
68
+ db2 = new sqlite3 . Database ( 'file:./test/tmp/test_memory.db?mode=memory' , sqlite3 . OPEN_URI | sqlite3 . OPEN_SHAREDCACHE | sqlite3 . OPEN_READWRITE | sqlite3 . OPEN_CREATE , done ) ;
69
+ } ) ;
70
+
71
+ it ( 'first database should set the user_version' , function ( done ) {
72
+ db1 . exec ( 'PRAGMA user_version=42' , done ) ;
73
+ } ) ;
74
+
75
+ it ( 'second database should get the user_version' , function ( done ) {
76
+ db2 . get ( 'PRAGMA user_version' , function ( err , row ) {
77
+ if ( err ) throw err ;
78
+ assert . equal ( row . user_version , 42 ) ;
79
+ done ( ) ;
80
+ } ) ;
81
+ } ) ;
82
+
83
+ it ( 'should close the first database' , function ( done ) {
84
+ db1 . close ( done ) ;
85
+ } ) ;
86
+
87
+ it ( 'should close the second database' , function ( done ) {
88
+ db2 . close ( done ) ;
89
+ } ) ;
90
+ } ) ;
33
91
34
92
it ( 'should not be unable to open an inaccessible database' , function ( done ) {
35
93
// NOTE: test assumes that the user is not allowed to create new files
0 commit comments