update tests

This commit is contained in:
Philipp Kunz 2017-09-13 13:47:38 +02:00
parent c74873d02c
commit 14042151ba
5 changed files with 13 additions and 13 deletions

View File

@ -58,4 +58,4 @@ class DbDoc {
}
}
exports.DbDoc = DbDoc;
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic21hcnRkYXRhLmNsYXNzZXMuZGJkb2MuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi90cy9zbWFydGRhdGEuY2xhc3Nlcy5kYmRvYy50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOztBQUVBLDZCQUErQjtBQU8vQjs7R0FFRztBQUNIO0lBQ0UsTUFBTSxDQUFDLENBQUMsTUFBa0IsRUFBRSxHQUFXO1FBQ3JDLE9BQU8sQ0FBQyxHQUFHLENBQUMsWUFBWSxDQUFDLENBQUE7UUFDekIsRUFBRSxDQUFDLENBQUMsQ0FBQyxNQUFNLENBQUMsa0JBQWtCLENBQUMsQ0FBQyxDQUFDO1lBQUMsTUFBTSxDQUFDLGtCQUFrQixHQUFHLEVBQUUsQ0FBQTtRQUFDLENBQUM7UUFDbEUsTUFBTSxDQUFDLGtCQUFrQixDQUFDLElBQUksQ0FBQyxHQUFHLENBQUMsQ0FBQTtJQUNyQyxDQUFDLENBQUE7QUFDSCxDQUFDO0FBTkQsb0JBTUM7QUFFRDtJQXNCRTs7T0FFRztJQUNIO1FBQ0UsSUFBSSxDQUFDLElBQUksR0FBRyxJQUFJLENBQUMsV0FBVyxDQUFDLE1BQU0sQ0FBQyxDQUFBO1FBQ3BDLElBQUksQ0FBQyxVQUFVLEdBQUcsSUFBSSxDQUFDLFdBQVcsQ0FBRSxjQUFjLENBQUUsQ0FBQTtJQUN0RCxDQUFDO0lBRUQ7OztPQUdHO0lBQ0gsSUFBSTtRQUNGLElBQUksY0FBYyxHQUFRLEVBQUUsQ0FBQSxDQUFDLCtDQUErQztRQUM1RSxHQUFHLENBQUMsQ0FBQyx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lodash": "^4.14.69",
"@types/mongodb": "^2.2.7",
"@types/lodash": "^4.14.74",
"@types/mongodb": "^2.2.11",
"beautylog": "^6.1.10",
"lik": "^1.0.38",
"lik": "^1.0.40",
"lodash": "^4.17.4",
"mongodb": "^2.2.30",
"mongodb": "^2.2.31",
"runtime-type-checks": "0.0.4",
"smartq": "^1.1.6",
"typings-global": "^1.0.19"
"typings-global": "^1.0.20"
},
"devDependencies": {
"@types/shelljs": "^0.7.2",
"@types/shelljs": "^0.7.4",
"qenv": "^1.1.7",
"shelljs": "^0.7.8",
"smartstring": "^2.0.24",

View File

@ -5,13 +5,13 @@ import { Qenv } from 'qenv'
let testQenv = new Qenv(process.cwd(), process.cwd() + '/.nogit/')
// the tested module
import * as smartdata from '../dist/index'
import * as smartdata from '../ts/index'
let mongoChildProcess
let testDb: smartdata.Db
tap.test('should establish a connection to mongodb', async () => {
testDb = new smartdata.Db(`mongodb://${process.env.MONGO_USER}:${process.env.MONGO_PASS}@sandbox-shard-00-00-uyw7y.mongodb.net:27017,sandbox-shard-00-01-uyw7y.mongodb.net:27017,sandbox-shard-00-02-uyw7y.mongodb.net:27017/${process.env.MONGO_DATABASE}?ssl=true&replicaSet=sandbox-shard-0&authSource=admin`)
testDb = new smartdata.Db(`mongodb://${process.env.MONGO_USER}:${process.env.MONGO_PASS}@sandbox-shard-00-00-uyw7y.mongodb.net:27017,sandbox-shard-00-01-uyw7y.mongodb.net:27017,sandbox-shard-00-02-uyw7y.mongodb.net:27017/${process.env.MONGO_DATABASE}?ssl=true&replicaSet=sandbox-shard-0&authSource=admin`)
await testDb.connect()
})

View File

@ -5,7 +5,7 @@ import { Qenv } from 'qenv'
let testQenv = new Qenv(process.cwd(), process.cwd() + '/.nogit/')
// the tested module
import * as smartdata from '../dist/index'
import * as smartdata from '../ts/index'
let mongoChildProcess
let testDb: smartdata.Db

View File

@ -52,7 +52,7 @@ export class DbDoc<T> {
* saves this instance but not any connected items
* may lead to data inconsistencies, but is faster
*/
save() {
save () {
let saveableObject: any = {} // is not exposed to outside, so any is ok here
for (let propertyNameString of this.saveableProperties) {
saveableObject[ propertyNameString ] = this[ propertyNameString ]
@ -70,14 +70,14 @@ export class DbDoc<T> {
* also store any referenced objects to DB
* better for data consistency
*/
saveDeep(savedMapArg: Objectmap<DbDoc<any>> = null) {
saveDeep (savedMapArg: Objectmap<DbDoc<any>> = null) {
if (!savedMapArg) {
savedMapArg = new Objectmap<DbDoc<any>>()
}
savedMapArg.add(this)
this.save()
for (let propertyKey in this) {
let property = this[ propertyKey ]
let property: any = this[ propertyKey ]
if (property instanceof DbDoc && !savedMapArg.checkForObject(property)) {
property.saveDeep(savedMapArg)
}