@@ -34,11 +34,7 @@ const REDmock = {
3434 node [ key ] = config [ key ] ;
3535 }
3636 }
37- // Provide credentials from the test environment
38- node . credentials = {
39- user : ORACLEDBTEST_USER ,
40- password : ORACLEDBTEST_PASSWORD
41- } ;
37+ node . credentials = { user : ORACLEDBTEST_USER , password : ORACLEDBTEST_PASSWORD } ;
4238 node . log = ( msg ) => console . log ( `[LOG] ${ msg } ` ) ;
4339 node . error = ( msg ) => console . error ( `[ERROR] ${ msg } ` ) ;
4440 node . warn = ( msg ) => console . warn ( `[WARN] ${ msg } ` ) ;
@@ -48,13 +44,16 @@ const REDmock = {
4844 registerType : function ( nodeName , constructor ) {
4945 testNodes [ nodeName ] = constructor ;
5046 } ,
51- getNode : ( id ) => id
47+ getNode : ( id ) => id ,
48+ // Add the RED.util.cloneMessage mock
49+ util : {
50+ cloneMessage : ( msg ) => JSON . parse ( JSON . stringify ( msg ) )
51+ }
5252 }
5353} ;
5454
5555oracleNodes ( REDmock ) ;
5656
57- // --- Build the server configuration based on the environment ---
5857const serverConfig = {
5958 instantclientpath : ORACLEDBTEST_INSTANT_CLIENT_PATH ,
6059 connectiontype : ORACLEDBTEST_CONNECTION_TYPE || "Classic" ,
@@ -68,14 +67,13 @@ const serverConfig = {
6867 pooltimeout : 30
6968} ;
7069
71- // Helper function to simulate a message arriving at a node's input
7270function sendMessage ( node , msg , done ) {
7371 node . send = ( msgOut ) => {
7472 console . log ( "[SEND]" , msgOut ) ;
7573 done ( ) ;
7674 } ;
7775 node . error = ( err ) => {
78- done ( new Error ( err ) ) ; // Fail the test if the node calls .error()
76+ done ( new Error ( err ) ) ;
7977 } ;
8078 nodeListener . emit ( "input" , msg ) ;
8179}
@@ -91,35 +89,29 @@ describe("Test Node Registration", function() {
9189} ) ;
9290
9391
94- // --- Rewritten Live Database Tests ---
9592describe ( "Live Database Tests" , function ( ) {
96- this . timeout ( 10000 ) ; // Increase timeout for potentially slow remote connections
93+ this . timeout ( 10000 ) ;
9794
9895 const canRunLiveTests = ! ! ( ORACLEDBTEST_INSTANT_CLIENT_PATH && ORACLEDBTEST_USER ) ;
9996
10097 before ( function ( ) {
10198 if ( ! canRunLiveTests ) {
102- console . warn ( "\nSkipping live database tests. Please create a .env file with test credentials (see README for details) .\n" ) ;
99+ console . warn ( "\nSkipping live database tests. Please create a .env file with test credentials.\n" ) ;
103100 this . skip ( ) ;
104101 }
105102 } ) ;
106103
107104 const serverNode = new testNodes [ "oracle-server" ] ( serverConfig ) ;
108105
109106 it ( "should create an Oracle database connection pool" , function ( done ) {
110- // FIX THE RACE CONDITION: Check if the pool is already connected.
111107 if ( serverNode . pool ) {
112- // If the pool exists, the "connected" event already fired. We can pass immediately.
113108 expect ( serverNode . pool ) . to . not . be . null ;
114109 return done ( ) ;
115110 }
116-
117- // If the pool is not yet ready, it's safe to listen for the events.
118111 serverNode . status . once ( "connected" , ( ) => {
119112 expect ( serverNode . pool ) . to . not . be . null ;
120113 done ( ) ;
121114 } ) ;
122-
123115 serverNode . status . once ( "error" , ( err ) => {
124116 done ( new Error ( err . message ) ) ;
125117 } ) ;
@@ -128,6 +120,7 @@ describe("Live Database Tests", function() {
128120 it ( "should successfully execute a query" , function ( done ) {
129121 const queryNode = {
130122 log : ( ) => { } ,
123+ status : ( ) => { } , // Add the mock status function
131124 error : ( msg ) => done ( new Error ( msg ) ) ,
132125 send : ( msg ) => {
133126 expect ( msg . payload ) . to . be . an ( "array" ) . with . lengthOf ( 1 ) ;
@@ -140,6 +133,7 @@ describe("Live Database Tests", function() {
140133 it ( "should successfully execute a query with a parameter" , function ( done ) {
141134 const queryNode = {
142135 log : ( ) => { } ,
136+ status : ( ) => { } , // Add the mock status function
143137 error : ( msg ) => done ( new Error ( msg ) ) ,
144138 send : ( msg ) => {
145139 expect ( msg . payload ) . to . be . an ( "array" ) . with . lengthOf ( 1 ) ;
@@ -158,14 +152,14 @@ describe("Live Database Tests", function() {
158152 resultaction : "single" ,
159153 server : serverNode ,
160154 usemappings : false ,
155+ mappings : "[]" ,
161156 resultlimit : 100
162157 } ;
163158 const queryNode = new testNodes [ "oracledb" ] ( queryConfig ) ;
164159 const msg = { payload : [ ] } ;
165160 sendMessage ( queryNode , msg , done ) ;
166161 } ) ;
167162
168- // Clean up the pool after tests are done
169163 after ( async function ( ) {
170164 if ( serverNode && serverNode . pool ) {
171165 await serverNode . pool . close ( 0 ) ;
0 commit comments