@@ -6,30 +6,32 @@ const IMAGE = getImage(__dirname);
66const images = [ "opensearchproject/opensearch:2.19.2" , IMAGE ] ;
77
88describe ( "OpenSearchContainer" , { timeout : 180_000 } , ( ) => {
9- // createIndex {
109 it . each ( images ) ( "should create an index with %s" , async ( image ) => {
10+ // opensearchCreateIndex {
1111 await using container = await new OpenSearchContainer ( image ) . start ( ) ;
12+
1213 const client = new Client ( {
1314 node : container . getHttpUrl ( ) ,
1415 auth : {
1516 username : container . getUsername ( ) ,
1617 password : container . getPassword ( ) ,
1718 } ,
1819 ssl : {
19- // trust the self-signed cert
2020 rejectUnauthorized : false ,
2121 } ,
2222 } ) ;
2323
2424 await client . indices . create ( { index : "people" } ) ;
25- const existsResponse = await client . indices . exists ( { index : "people" } ) ;
26- expect ( existsResponse . body ) . toBe ( true ) ;
25+
26+ const { body } = await client . indices . exists ( { index : "people" } ) ;
27+ expect ( body ) . toBe ( true ) ;
28+ // }
2729 } ) ;
28- // }
2930
30- // indexDocument {
3131 it ( "should index a document" , async ( ) => {
32+ // opensearchIndexDocument {
3233 await using container = await new OpenSearchContainer ( IMAGE ) . start ( ) ;
34+
3335 const client = new Client ( {
3436 node : container . getHttpUrl ( ) ,
3537 auth : {
@@ -49,10 +51,10 @@ describe("OpenSearchContainer", { timeout: 180_000 }, () => {
4951 body : document ,
5052 } ) ;
5153
52- const getResponse = await client . get ( { index : "people" , id : document . id } ) ;
53- expect ( getResponse . body . _source ) . toStrictEqual ( document ) ;
54+ const { body } = await client . get ( { index : "people" , id : document . id } ) ;
55+ expect ( body . _source ) . toEqual ( document ) ;
56+ // }
5457 } ) ;
55- // }
5658
5759 it ( "should work with restarted container" , async ( ) => {
5860 await using container = await new OpenSearchContainer ( IMAGE ) . start ( ) ;
@@ -70,6 +72,7 @@ describe("OpenSearchContainer", { timeout: 180_000 }, () => {
7072 } ) ;
7173
7274 await client . indices . create ( { index : "people" } ) ;
75+
7376 const existsResponse = await client . indices . exists ( { index : "people" } ) ;
7477 expect ( existsResponse . body ) . toBe ( true ) ;
7578 } ) ;
@@ -78,9 +81,10 @@ describe("OpenSearchContainer", { timeout: 180_000 }, () => {
7881 expect ( ( ) => new OpenSearchContainer ( IMAGE ) . withPassword ( "weakpwd" ) ) . toThrowError ( / P a s s w o r d " w e a k p w d " i s t o o w e a k / ) ;
7982 } ) ;
8083
81- // customPassword {
8284 it ( "should set custom password" , async ( ) => {
85+ // opensearchCustomPassword {
8386 await using container = await new OpenSearchContainer ( IMAGE ) . withPassword ( "Str0ng!Passw0rd2025" ) . start ( ) ;
87+ // }
8488
8589 const client = new Client ( {
8690 node : container . getHttpUrl ( ) ,
@@ -94,8 +98,8 @@ describe("OpenSearchContainer", { timeout: 180_000 }, () => {
9498 } ) ;
9599
96100 await client . indices . create ( { index : "people" } ) ;
97- const existsResponse = await client . indices . exists ( { index : "people" } ) ;
98- expect ( existsResponse . body ) . toBe ( true ) ;
101+
102+ const { body } = await client . indices . exists ( { index : "people" } ) ;
103+ expect ( body ) . toBe ( true ) ;
99104 } ) ;
100- // }
101105} ) ;
0 commit comments