@@ -35,45 +35,49 @@ const testsUtil = require('./testsUtil.js');
35
35
36
36
describe ( '178. soda10.js' , ( ) => {
37
37
38
+ let runnable ;
38
39
let conn , soda ;
39
40
40
41
before ( async function ( ) {
41
- try {
42
- const runnable = await testsUtil . checkPrerequisites ( ) ;
43
- if ( ! runnable ) {
44
- this . skip ( ) ;
45
- return ;
46
- } else {
47
- await sodaUtil . cleanup ( ) ;
48
- conn = await oracledb . getConnection ( dbconfig ) ;
49
- soda = conn . getSodaDatabase ( ) ;
50
- }
51
42
52
- } catch ( err ) {
53
- should . not . exist ( err ) ;
43
+ const runnable = await testsUtil . checkPrerequisites ( ) ;
44
+
45
+ if ( ! runnable ) {
46
+ this . skip ( ) ;
47
+ return ;
48
+ } else {
49
+ conn = await oracledb . getConnection ( dbconfig ) ;
50
+ soda = conn . getSodaDatabase ( ) ;
54
51
}
52
+
53
+ await sodaUtil . cleanup ( ) ;
54
+
55
55
} ) ; // before()
56
56
57
- after ( async ( ) => {
57
+ after ( async function ( ) {
58
+ if ( ! runnable ) {
59
+ this . skip ( ) ;
60
+ return ;
61
+ }
58
62
try {
59
-
60
63
await conn . close ( ) ;
61
64
} catch ( err ) {
62
65
should . not . exist ( err ) ;
63
66
}
64
67
} ) ; // after()
65
68
66
- it ( '178.1 basic case of sodaCollection.insertMany()' , async ( ) => {
69
+ const inContents = [
70
+ { id : 1 , name : "Paul" , office : "Singapore" } ,
71
+ { id : 2 , name : "Emma" , office : "London" } ,
72
+ { id : 3 , name : "Kate" , office : "Edinburgh" } ,
73
+ { id : 4 , name : "Changjie" , office : "Shenzhen" }
74
+ ] ;
75
+
76
+ it ( '178.1 insertMany() with newSodaDocumentArray' , async ( ) => {
67
77
try {
68
78
const COLL = "soda_test_178_1" ;
69
79
const collection = await soda . createCollection ( COLL ) ;
70
80
71
- let inContents = [
72
- { id : 1 , name : "Paul" , office : "Singapore" } ,
73
- { id : 2 , name : "Emma" , office : "London" } ,
74
- { id : 3 , name : "Kate" , office : "Edinburgh" } ,
75
- { id : 4 , name : "Changjie" , office : "Shenzhen" }
76
- ] ;
77
81
let inDocuments = [ ] ;
78
82
for ( let i = 0 ; i < inContents . length ; i ++ ) {
79
83
inDocuments [ i ] = soda . createDocument ( inContents [ i ] ) ; // n.b. synchronous method
@@ -99,17 +103,36 @@ describe('178. soda10.js', () => {
99
103
}
100
104
} ) ; // 178.1
101
105
102
- it . skip ( '178.2 basic case of sodaCollection.insertManyAndGet() ' , async ( ) => {
106
+ it ( '178.2 insertMany() with newSodaDocumentContentArray ' , async ( ) => {
103
107
try {
104
108
const COLL = "soda_test_178_2" ;
105
109
const collection = await soda . createCollection ( COLL ) ;
106
110
107
- let inContents = [
108
- { id : 1 , name : "Paul" , office : "Singapore" } ,
109
- { id : 2 , name : "Emma" , office : "London" } ,
110
- { id : 3 , name : "Kate" , office : "Edinburgh" } ,
111
- { id : 4 , name : "Changjie" , office : "Shenzhen" }
112
- ] ;
111
+ await collection . insertMany ( inContents ) ;
112
+
113
+ // Fetch back
114
+ let outDocuments = await collection . find ( ) . getDocuments ( ) ;
115
+ let outContents = [ ] ;
116
+ for ( let i = 0 ; i < outDocuments . length ; i ++ ) {
117
+ outContents [ i ] = outDocuments [ i ] . getContent ( ) ; // n.b. synchronous method
118
+ }
119
+
120
+ should . deepEqual ( outContents , inContents ) ;
121
+
122
+ await conn . commit ( ) ;
123
+
124
+ let res = await collection . drop ( ) ;
125
+ should . strictEqual ( res . dropped , true ) ;
126
+ } catch ( err ) {
127
+ should . not . exist ( err ) ;
128
+ }
129
+ } ) ; // 178.2
130
+
131
+ it ( '178.3 insertManyAndGet() with newDocumentArray' , async ( ) => {
132
+ try {
133
+ const COLL = "soda_test_178_3" ;
134
+ const collection = await soda . createCollection ( COLL ) ;
135
+
113
136
let inDocuments = [ ] ;
114
137
for ( let i = 0 ; i < inContents . length ; i ++ ) {
115
138
inDocuments [ i ] = soda . createDocument ( inContents [ i ] ) ; // n.b. synchronous method
@@ -118,9 +141,68 @@ describe('178. soda10.js', () => {
118
141
let middleDocuments = await collection . insertManyAndGet ( inDocuments ) ;
119
142
let middleContents = [ ] ;
120
143
for ( let i = 0 ; i < middleDocuments . length ; i ++ ) {
121
- middleContents [ i ] = middleDocuments [ i ] . getContent ( ) ; // n.b. synchronous method
144
+ middleContents [ i ] = middleDocuments [ i ] . getContent ( ) ;
145
+ should . exist ( middleDocuments [ i ] . key ) ;
122
146
}
123
- console . log ( middleContents ) ;
147
+ should . deepEqual ( middleContents , [ null , null , null , null ] ) ;
148
+
149
+ // Fetch back
150
+ let outDocuments = await collection . find ( ) . getDocuments ( ) ;
151
+ let outContents = [ ] ;
152
+ for ( let i = 0 ; i < outDocuments . length ; i ++ ) {
153
+ outContents [ i ] = outDocuments [ i ] . getContent ( ) ; // n.b. synchronous method
154
+ }
155
+
156
+ should . deepEqual ( outContents , inContents ) ;
157
+
158
+ await conn . commit ( ) ;
159
+
160
+ let res = await collection . drop ( ) ;
161
+ should . strictEqual ( res . dropped , true ) ;
162
+ } catch ( err ) {
163
+ should . not . exist ( err ) ;
164
+ }
165
+ } ) ; // 178.3
166
+
167
+ it ( '178.4 insertManyAndGet() with newDocumentContentArray' , async ( ) => {
168
+ try {
169
+ const COLL = "soda_test_178_4" ;
170
+ const collection = await soda . createCollection ( COLL ) ;
171
+
172
+ let middleDocuments = await collection . insertManyAndGet ( inContents ) ;
173
+ let middleContents = [ ] ;
174
+ for ( let i = 0 ; i < middleDocuments . length ; i ++ ) {
175
+ middleContents [ i ] = middleDocuments [ i ] . getContent ( ) ;
176
+ should . exist ( middleDocuments [ i ] . key ) ;
177
+ }
178
+ should . deepEqual ( middleContents , [ null , null , null , null ] ) ;
179
+
180
+ // Fetch back
181
+ let outDocuments = await collection . find ( ) . getDocuments ( ) ;
182
+ let outContents = [ ] ;
183
+ for ( let i = 0 ; i < outDocuments . length ; i ++ ) {
184
+ outContents [ i ] = outDocuments [ i ] . getContent ( ) ; // n.b. synchronous method
185
+ }
186
+
187
+ should . deepEqual ( outContents , inContents ) ;
188
+
189
+ await conn . commit ( ) ;
190
+
191
+ let res = await collection . drop ( ) ;
192
+ should . strictEqual ( res . dropped , true ) ;
193
+ } catch ( err ) {
194
+ should . not . exist ( err ) ;
195
+ }
196
+ } ) ; // 178.4
197
+
198
+ it . skip ( '174.5 Negative - insertMany() with empty array' , async ( ) => {
199
+ try {
200
+ const COLL = "soda_test_178_5" ;
201
+ const collection = await soda . createCollection ( COLL ) ;
202
+
203
+ // ORA-40673: arrayLength argument cannot be NULL.
204
+ let inDocuments = [ ] ;
205
+ await collection . insertMany ( inDocuments ) ;
124
206
125
207
// Fetch back
126
208
let outDocuments = await collection . find ( ) . getDocuments ( ) ;
@@ -130,6 +212,7 @@ describe('178. soda10.js', () => {
130
212
}
131
213
132
214
console . log ( outContents ) ;
215
+ // should.deepEqual(outContents, inContents);
133
216
134
217
await conn . commit ( ) ;
135
218
@@ -138,5 +221,6 @@ describe('178. soda10.js', () => {
138
221
} catch ( err ) {
139
222
should . not . exist ( err ) ;
140
223
}
141
- } ) ; // 178.2
224
+ } ) ; // 174.5
225
+
142
226
} ) ;
0 commit comments