Skip to content

Commit

Permalink
Adds test for cached Model.get() with instance.cacheSaveCheck disabled (
Browse files Browse the repository at this point in the history
  • Loading branch information
dresende committed Mar 15, 2013
1 parent 473a6f4 commit c578640
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions test/integration/test-get-cache-no-save-check.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
var common = require('../common');
var assert = require('assert');

common.createConnection(function (err, db) {
common.createModelTable('test_get_cache', db.driver.db, function () {
common.insertModelData('test_get_cache', db.driver.db, [
{ id : 1, name : 'test' }
], function (err) {
if (err) throw err;

db.settings.set("instance.cacheSaveCheck", false);

var TestModel = db.define('test_get_cache', common.getModelProperties());

// this is the default, it's just here in case default changes..
TestModel.get(1, { cache: true }, function (err, Instance1) {
assert.equal(err, null);
assert.equal(typeof Instance1, "object");
assert.equal(Instance1.id, 1);
assert.equal(Instance1.name, 'test');

Instance1.name = 'test1';

TestModel.get(1, { cache: true }, function (err, Instance2) {
assert.equal(err, null);
assert.equal(typeof Instance2, "object");
assert.equal(Instance2.id, 1);
assert.equal(Instance2.name, 'test1'); // no save check
db.close();
});
});
});
});
});

0 comments on commit c578640

Please sign in to comment.