@@ -67,3 +67,46 @@ t.test('open IAM connection and run basic mysql commands', async t => {
67
67
await conn . end ( ) ;
68
68
connector . close ( ) ;
69
69
} ) ;
70
+
71
+ t . test ( 'open connection and run basic mysql commands' , async t => {
72
+ const connector = new Connector ( ) ;
73
+ const clientOpts = await connector . getOptions ( {
74
+ instanceConnectionName : String ( process . env . MYSQL_MCP_CONNECTION_NAME ) ,
75
+ ipType : process . env . IP_TYPE || IpAddressTypes . PUBLIC ,
76
+ } ) ;
77
+ const conn = await mysql . createConnection ( {
78
+ ...clientOpts ,
79
+ user : String ( process . env . MYSQL_USER ) ,
80
+ password : String ( process . env . MYSQL_MCP_PASS ) ,
81
+ database : String ( process . env . MYSQL_DB ) ,
82
+ } ) ;
83
+
84
+ const [ result ] = await conn . query < Now [ ] > ( 'SELECT NOW();' ) ;
85
+ const [ row ] = result ;
86
+ const returnedDate = row [ 'NOW()' ] ;
87
+ t . ok ( returnedDate . getTime ( ) , 'should have valid returned date object' ) ;
88
+
89
+ await conn . end ( ) ;
90
+ connector . close ( ) ;
91
+ } ) ;
92
+
93
+ t . test ( 'open IAM connection and run basic mysql commands' , async t => {
94
+ const connector = new Connector ( ) ;
95
+ const clientOpts = await connector . getOptions ( {
96
+ instanceConnectionName : String ( process . env . MYSQL_MCP_CONNECTION_NAME ) ,
97
+ ipType : process . env . IP_TYPE || IpAddressTypes . PUBLIC ,
98
+ authType : AuthTypes . IAM ,
99
+ } ) ;
100
+ const conn = await mysql . createConnection ( {
101
+ ...clientOpts ,
102
+ user : String ( process . env . MYSQL_IAM_USER ) ,
103
+ database : String ( process . env . MYSQL_DB ) ,
104
+ } ) ;
105
+
106
+ const [ [ result ] ] = await conn . query < Now [ ] > ( 'SELECT NOW();' ) ;
107
+ const returnedDate = result [ 'NOW()' ] ;
108
+ t . ok ( returnedDate . getTime ( ) , 'should have valid returned date object' ) ;
109
+
110
+ await conn . end ( ) ;
111
+ connector . close ( ) ;
112
+ } ) ;
0 commit comments