Skip to content

Commit

Permalink
Add tests that check for empty tables
Browse files Browse the repository at this point in the history
  • Loading branch information
myisaak committed Dec 8, 2021
1 parent ac8648e commit 0307fd3
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions test.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
const sqlitemongo = require('./sqlitemongo');
const { MongoClient } = require("mongodb");
const path = require('path');
const { assert } = require('console');
const SQLITE_PATH = "./test.sqlite3";
const GH_ACTION_MONGO_URI = "mongodb://localhost:42069";
Expand Down Expand Up @@ -37,13 +36,18 @@ async function testRemote() {
async function verifyResult() {
const mongoConnected = await MongoClient.connect(GH_ACTION_MONGO_URI);
const mongoDb = mongoConnected.db("sqlite3");
const items = await mongoDb.collection("Test").find().toArray();
let items = await mongoDb.collection("Test").find().toArray();
assert(items.length === 1, "Count of items in Test database should be 1");
const item = items[0];
assert(item, "First item should be a value, instead is Falsy");
assert(item.Test_Int === 12414142, "Test_Int should be 12414142");
assert(item.Test_Str === "Hello", "Test_Str should be 'Hello'");
assert(item.Test_Real === -241.3252, "Test_Real should be -241.3252");
assert(item.Test_Num === -42522, "Test_Num should be -42522");

items = await mongoDb.collection("Empty Table").find().toArray();
assert(items.length === 0, "Cound of items in 'Empty Table' should be 0");
assert()

return mongoConnected.close();
}
Binary file modified test.sqlite3
Binary file not shown.

0 comments on commit 0307fd3

Please sign in to comment.