@@ -5,8 +5,8 @@ import { CockroachDbContainer } from "./cockroachdb-container";
55const IMAGE = getImage ( __dirname ) ;
66
77describe ( "CockroachDbContainer" , { timeout : 180_000 } , ( ) => {
8- // connect {
98 it ( "should connect and return a query result" , async ( ) => {
9+ // cockroachConnect {
1010 await using container = await new CockroachDbContainer ( IMAGE ) . start ( ) ;
1111
1212 const client = new Client ( {
@@ -23,62 +23,65 @@ describe("CockroachDbContainer", { timeout: 180_000 }, () => {
2323 expect ( result . rows [ 0 ] ) . toEqual ( { "?column?" : "1" } ) ;
2424
2525 await client . end ( ) ;
26+ // }
2627 } ) ;
27- // }
2828
29- // uriConnect {
3029 it ( "should work with database URI" , async ( ) => {
30+ // uriConnect {
3131 await using container = await new CockroachDbContainer ( IMAGE ) . start ( ) ;
3232
3333 const client = new Client ( {
3434 connectionString : container . getConnectionUri ( ) ,
3535 } ) ;
36+ // }
37+
3638 await client . connect ( ) ;
3739
3840 const result = await client . query ( "SELECT 1" ) ;
3941 expect ( result . rows [ 0 ] ) . toEqual ( { "?column?" : "1" } ) ;
4042
4143 await client . end ( ) ;
4244 } ) ;
43- // }
4445
45- // setDatabase {
4646 it ( "should set database" , async ( ) => {
47+ // setDatabase {
4748 await using container = await new CockroachDbContainer ( IMAGE ) . withDatabase ( "custom_database" ) . start ( ) ;
49+ // }
4850
4951 const client = new Client ( {
5052 host : container . getHost ( ) ,
5153 port : container . getPort ( ) ,
5254 database : container . getDatabase ( ) ,
5355 user : container . getUsername ( ) ,
5456 } ) ;
57+
5558 await client . connect ( ) ;
5659
5760 const result = await client . query ( "SELECT current_database()" ) ;
5861 expect ( result . rows [ 0 ] ) . toEqual ( { current_database : "custom_database" } ) ;
5962
6063 await client . end ( ) ;
6164 } ) ;
62- // }
6365
64- // setUsername {
6566 it ( "should set username" , async ( ) => {
67+ // setUsername {
6668 await using container = await new CockroachDbContainer ( IMAGE ) . withUsername ( "custom_username" ) . start ( ) ;
69+ // }
6770
6871 const client = new Client ( {
6972 host : container . getHost ( ) ,
7073 port : container . getPort ( ) ,
7174 database : container . getDatabase ( ) ,
7275 user : container . getUsername ( ) ,
7376 } ) ;
77+
7478 await client . connect ( ) ;
7579
7680 const result = await client . query ( "SELECT current_user" ) ;
7781 expect ( result . rows [ 0 ] ) . toEqual ( { current_user : "custom_username" } ) ;
7882
7983 await client . end ( ) ;
8084 } ) ;
81- // }
8285
8386 it ( "should work with restarted container" , async ( ) => {
8487 await using container = await new CockroachDbContainer ( IMAGE ) . start ( ) ;
0 commit comments