@@ -109,4 +109,67 @@ describe('chDB Connection Tests', function () {
109109 } ) ;
110110 } ) ;
111111
112+ describe ( 'Session without Path (In-Memory)' , function ( ) {
113+ let session ;
114+
115+ it ( 'should create session successfully without path' , function ( ) {
116+ session = new Session ( ) ;
117+ expect ( session . path ) . to . not . be . null ;
118+ expect ( session . path ) . to . not . be . undefined ;
119+ expect ( session . connection ) . to . not . be . null ;
120+ expect ( session . connection ) . to . not . be . undefined ;
121+ console . log ( "✓ In-memory session created successfully" ) ;
122+ console . log ( "✓ Connection:" , session . connection ) ;
123+ } ) ;
124+
125+ it ( 'should execute simple query in memory session' , function ( ) {
126+ const result = session . query ( "SELECT 1 as test_col" , "CSV" ) ;
127+ console . log ( "Query result:" , result . trim ( ) ) ;
128+ expect ( result ) . to . be . a ( 'string' ) ;
129+ expect ( result . trim ( ) ) . to . equal ( '1' ) ;
130+ } ) ;
131+
132+ it ( 'should create table and insert data in memory session' , function ( ) {
133+ expect ( ( ) => {
134+ session . query ( "CREATE TABLE memory_test (id UInt32, name String) ENGINE = Memory" ) ;
135+ session . query ( "INSERT INTO memory_test VALUES (1, 'MemoryAlice'), (2, 'MemoryBob')" ) ;
136+ } ) . to . not . throw ( ) ;
137+ console . log ( "✓ Memory table created and data inserted successfully" ) ;
138+ } ) ;
139+
140+ it ( 'should query data from memory table' , function ( ) {
141+ const result = session . query ( "SELECT * FROM memory_test ORDER BY id" , "CSV" ) ;
142+ console . log ( "Memory query result:" , result . trim ( ) ) ;
143+ expect ( result ) . to . be . a ( 'string' ) ;
144+ expect ( result ) . to . include ( 'MemoryAlice' ) ;
145+ expect ( result ) . to . include ( 'MemoryBob' ) ;
146+ expect ( result ) . to . include ( '1' ) ;
147+ expect ( result ) . to . include ( '2' ) ;
148+ } ) ;
149+
150+ it ( 'should cleanup session and verify data is not accessible in new session' , function ( ) {
151+ // Cleanup the current session
152+ session . cleanup ( ) ;
153+ console . log ( "✓ Memory session cleaned up" ) ;
154+
155+ // Create a new session without path
156+ session = new Session ( ) ;
157+ console . log ( "✓ New memory session created" ) ;
158+
159+ // Try to query the previous table - should fail or return empty
160+ expect ( ( ) => {
161+ const result = session . query ( "SELECT * FROM memory_test" , "CSV" ) ;
162+ } ) . to . throw ( ) ; // Expected to throw error since table shouldn't exist
163+
164+ console . log ( "✓ Data correctly cleaned up - table not accessible in new session" ) ;
165+ } ) ;
166+
167+ after ( function ( ) {
168+ // Clean up the session after all tests are done
169+ if ( session ) {
170+ session . cleanup ( ) ;
171+ }
172+ } ) ;
173+ } ) ;
174+
112175} ) ;
0 commit comments