0.1.9 • Published 4 years ago

mgnlq_testmodel_replay v0.1.9

Weekly downloads
25
License
MIT
Repository
github
Last release
4 years ago

mgnlq_testmodel_replay Build StatusCoverage Status

The mongo testmodel replay files and an hard coded instantiation hook assuming:

Property | Value (hard coded!)

Mongo DB Connection string'mongodb://localhost/testdb'
data Foldermgrecrep/

Note: in default mode no mongo connection is established and REPLAY mode is on. (see mongoose_record_replay)

usage

plain hook:

    const Model = require('mgnlq_model');

    require('mgnlq_testmodel_replay').getTestModel().then( theModel =>
        {
            // your code using theModel
            Model.releaseModel(theModel);
        }
    );

just use file storage.

    var mongooseMock = require('mongoose_record_replay').instrumentMongoose(require('mongoose'),
        'node_modules/mgnlq_testmodel_replay/mgrecrep/',
        mode);
    var aPromise = undefined;
    function getModel() {
        if(mode === 'REPLAY') {
            // in replay mode during testing, using a singleton is sufficient
            aPromise = aPromise || Model.loadModelsOpeningConnection(mongooseMock,'mongodb://localhost/testdb'  );
            return aPromise;
    }
    // open a real connection, which has to be closed
    return Model.loadModelsOpeningConnection(mongooseMock, 'mongodb://localhost/testdb');
}

environment Switching to Record mode ...

environment variable MGNLQ_TESTMODEL_REPLAY control the mode.

  1. REPLAY (default)
  2. RECORD
  3. OFF (access db)

Beware: the underlying model uses a caching mechanism, thus it attempts to write to folders.

Similar, in RECORD mode, mgrecrep/queries.json and mgrecrep/data may be extened with new files.

Tasks to maintain the model

Rebuilding the model from scratch (raw files)

goto mgnlq_model run env_reset.cmd npm run load_data

Updating the queries

changliest

starting wiht 0.1.1 files are located in the current dir /test/data/mongoose_record_replay/testmodel/ ..

0.1.9

4 years ago

0.1.8

4 years ago

0.1.7

5 years ago

0.1.6

5 years ago

0.1.5

5 years ago

0.1.4

5 years ago

0.1.3

5 years ago

0.1.2

5 years ago

0.1.1

5 years ago

0.0.15

5 years ago

0.0.14

5 years ago

0.0.13

5 years ago

0.0.12

5 years ago

0.0.11

5 years ago

0.0.9

5 years ago

0.0.8

5 years ago

0.0.7

7 years ago

0.0.6

7 years ago

0.0.5

7 years ago

0.0.4

7 years ago

0.0.3

7 years ago

0.0.2

7 years ago

0.0.1

7 years ago