@@ -5,8 +5,8 @@ import { MySqlContainer } from "./mysql-container";
55const IMAGE = getImage ( __dirname ) ;
66
77describe ( "MySqlContainer" , { timeout : 240_000 } , ( ) => {
8- // connect {
98 it ( "should connect and execute query" , async ( ) => {
9+ // mysqlConnect {
1010 await using container = await new MySqlContainer ( IMAGE ) . start ( ) ;
1111
1212 const client = await createConnection ( {
@@ -21,38 +21,38 @@ describe("MySqlContainer", { timeout: 240_000 }, () => {
2121 expect ( rows ) . toEqual ( [ { res : 1 } ] ) ;
2222
2323 await client . end ( ) ;
24+ // }
2425 } ) ;
25- // }
2626
27- // uriConnect {
2827 it ( "should work with database URI" , async ( ) => {
28+ // mysqlUriConnect {
2929 const username = "testUser" ;
3030 const password = "testPassword" ;
3131 const database = "testDB" ;
3232
33- // Test non-root user
3433 await using container = await new MySqlContainer ( IMAGE )
3534 . withUsername ( username )
3635 . withUserPassword ( password )
3736 . withDatabase ( database )
3837 . start ( ) ;
38+
3939 expect ( container . getConnectionUri ( ) ) . toEqual (
4040 `mysql://${ username } :${ password } @${ container . getHost ( ) } :${ container . getPort ( ) } /${ database } `
4141 ) ;
4242
43- // Test root user
4443 await using rootContainer = await new MySqlContainer ( IMAGE )
4544 . withRootPassword ( password )
4645 . withDatabase ( database )
4746 . start ( ) ;
47+
4848 expect ( rootContainer . getConnectionUri ( true ) ) . toEqual (
4949 `mysql://root:${ password } @${ rootContainer . getHost ( ) } :${ rootContainer . getPort ( ) } /${ database } `
5050 ) ;
51+ // }
5152 } ) ;
52- // }
5353
54- // setDatabase {
5554 it ( "should set database" , async ( ) => {
55+ // mysqlSetDatabase {
5656 await using container = await new MySqlContainer ( IMAGE ) . withDatabase ( "customDatabase" ) . start ( ) ;
5757
5858 const client = await createConnection ( {
@@ -67,10 +67,10 @@ describe("MySqlContainer", { timeout: 240_000 }, () => {
6767 expect ( rows ) . toEqual ( [ { res : "customDatabase" } ] ) ;
6868
6969 await client . end ( ) ;
70+ // }
7071 } ) ;
71- // }
7272
73- // setUsername {
73+ // mysqlSetUsername {
7474 it ( "should set username" , async ( ) => {
7575 await using container = await new MySqlContainer ( IMAGE ) . withUsername ( "customUsername" ) . start ( ) ;
7676
@@ -89,12 +89,13 @@ describe("MySqlContainer", { timeout: 240_000 }, () => {
8989 } ) ;
9090 // }
9191
92- // executeQuery {
9392 it ( "should execute a query and return the result" , async ( ) => {
93+ // mysqlExecuteQuery {
9494 await using container = await new MySqlContainer ( IMAGE ) . start ( ) ;
9595
96- const queryResult = await container . executeQuery ( "SELECT 1 as res" ) ;
97- expect ( queryResult ) . toEqual ( expect . stringContaining ( "res\n1\n" ) ) ;
96+ const result = await container . executeQuery ( "SELECT 1 as res" ) ;
97+ expect ( result ) . toEqual ( expect . stringContaining ( "res\n1\n" ) ) ;
98+ // }
9899 } ) ;
99100
100101 it ( "should execute a query as root user" , async ( ) => {
@@ -108,7 +109,6 @@ describe("MySqlContainer", { timeout: 240_000 }, () => {
108109 const rootQueryResult = await container . executeQuery ( "SELECT CURRENT_USER() as user" , [ ] , true ) ;
109110 expect ( rootQueryResult ) . toEqual ( expect . stringContaining ( "user\nroot" ) ) ;
110111 } ) ;
111- // }
112112
113113 it ( "should work with restarted container" , async ( ) => {
114114 await using container = await new MySqlContainer ( IMAGE ) . start ( ) ;
0 commit comments