Skip to content

Commit 19021a2

Browse files
committed
Add test for sodaCollection.insertManyAndGet()
1 parent 147dd0f commit 19021a2

File tree

1 file changed

+43
-2
lines changed

1 file changed

+43
-2
lines changed

test/soda10.js

Lines changed: 43 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ const testsUtil = require('./testsUtil.js');
3535

3636
describe('178. soda10.js', () => {
3737

38-
let conn;
38+
let conn, soda;
3939

4040
before(async function() {
4141
try {
@@ -46,6 +46,7 @@ describe('178. soda10.js', () => {
4646
} else {
4747
await sodaUtil.cleanup();
4848
conn = await oracledb.getConnection(dbconfig);
49+
soda = conn.getSodaDatabase();
4950
}
5051

5152
} catch (err) {
@@ -64,7 +65,6 @@ describe('178. soda10.js', () => {
6465

6566
it('178.1 basic case of sodaCollection.insertMany()', async () => {
6667
try {
67-
let soda = conn.getSodaDatabase();
6868
const COLL = "soda_test_178_1";
6969
const collection = await soda.createCollection(COLL);
7070

@@ -98,4 +98,45 @@ describe('178. soda10.js', () => {
9898
should.not.exist(err);
9999
}
100100
}); // 178.1
101+
102+
it.skip('178.2 basic case of sodaCollection.insertManyAndGet()', async () => {
103+
try {
104+
const COLL = "soda_test_178_2";
105+
const collection = await soda.createCollection(COLL);
106+
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+
];
113+
let inDocuments = [];
114+
for (let i = 0; i < inContents.length; i++) {
115+
inDocuments[i] = soda.createDocument(inContents[i]); // n.b. synchronous method
116+
}
117+
118+
let middleDocuments = await collection.insertManyAndGet(inDocuments);
119+
let middleContents = [];
120+
for (let i = 0; i < middleDocuments.length; i++) {
121+
middleContents[i] = middleDocuments[i].getContent(); // n.b. synchronous method
122+
}
123+
console.log(middleContents);
124+
125+
// Fetch back
126+
let outDocuments = await collection.find().getDocuments();
127+
let outContents = [];
128+
for (let i = 0; i < outDocuments.length; i++) {
129+
outContents[i] = outDocuments[i].getContent(); // n.b. synchronous method
130+
}
131+
132+
console.log(outContents);
133+
134+
await conn.commit();
135+
136+
let res = await collection.drop();
137+
should.strictEqual(res.dropped, true);
138+
} catch (err) {
139+
should.not.exist(err);
140+
}
141+
}); // 178.2
101142
});

0 commit comments

Comments
 (0)