@@ -38,7 +38,7 @@ describe('open/close', function() {
3838
3939 var db ;
4040 it ( 'should open the database' , function ( done ) {
41- db = new sqlite3 . Database ( 'test/tmp/test_create_shared.db' , sqlite3 . OPEN_SHAREDCACHE , 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 ) ;
4242 } ) ;
4343
4444 it ( 'should close the database' , function ( done ) {
@@ -54,6 +54,41 @@ describe('open/close', function() {
5454 } ) ;
5555 } ) ;
5656
57+
58+ 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+ } ) ;
91+
5792 it ( 'should not be unable to open an inaccessible database' , function ( done ) {
5893 // NOTE: test assumes that the user is not allowed to create new files
5994 // in /usr/bin.
0 commit comments