Uncomment tests
This commit is contained in:
parent
b56677c063
commit
59f873a4f2
|
@ -471,108 +471,86 @@ function testOrm(schema) {
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
// if (
|
it('hasMany should support additional conditions', function (test) {
|
||||||
// !schema.name.match(/redis/) &&
|
|
||||||
// schema.name !== 'memory' &&
|
|
||||||
// schema.name !== 'neo4j' &&
|
|
||||||
// schema.name !== 'cradle' &&
|
|
||||||
// schema.name !== 'nano' &&
|
|
||||||
// schema.name !== 'mongodb'
|
|
||||||
// )
|
|
||||||
// it('hasMany should support additional conditions', function (test) {
|
|
||||||
|
|
||||||
// // Finding one post with an existing author associated
|
User.create(function (e, u) {
|
||||||
// Post.all(function (err, posts) {
|
u.posts.create({}, function (e, p) {
|
||||||
// // We try to get the first post with a userId != NULL
|
u.posts({where: {id: p.id}}, function (e, posts) {
|
||||||
// for (var i = 0; i < posts.length; i++) {
|
test.equal(posts.length, 1, 'There should be only 1 post.');
|
||||||
// var post = posts[i];
|
test.done();
|
||||||
// if (post.userId !== null) {
|
});
|
||||||
// // We could get the user with belongs to relationship but it is better if there is no interactions.
|
});
|
||||||
// User.find(post.userId, function(err, user) {
|
});
|
||||||
// user.posts({where: {id: post.id}}, function(err, posts) {
|
|
||||||
// test.equal(posts.length, 1, 'There should be only 1 post.');
|
|
||||||
// test.done();
|
|
||||||
// });
|
|
||||||
// });
|
|
||||||
// break;
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// });
|
|
||||||
// });
|
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
// if (
|
it('hasMany should be cached', function (test) {
|
||||||
// !schema.name.match(/redis/) &&
|
//User.create(function (e, u) {
|
||||||
// schema.name !== 'memory' &&
|
// u.posts.create({}, function (e, p) {
|
||||||
// schema.name !== 'neo4j' &&
|
// Finding one post with an existing author associated
|
||||||
// schema.name !== 'cradle' &&
|
Post.all(function (err, posts) {
|
||||||
// schema.name !== 'nano'
|
// We try to get the first post with a userId != NULL
|
||||||
// )
|
for (var i = 0; i < posts.length; i++) {
|
||||||
// it('hasMany should be cached', function (test) {
|
var post = posts[i];
|
||||||
// // Finding one post with an existing author associated
|
if (post.userId) {
|
||||||
// Post.all(function (err, posts) {
|
// We could get the user with belongs to relationship but it is better if there is no interactions.
|
||||||
// // We try to get the first post with a userId != NULL
|
User.find(post.userId, function(err, user) {
|
||||||
// for (var i = 0; i < posts.length; i++) {
|
User.create(function(err, voidUser) {
|
||||||
// var post = posts[i];
|
Post.create({userId: user.id}, function() {
|
||||||
// if (post.userId !== null) {
|
|
||||||
// // We could get the user with belongs to relationship but it is better if there is no interactions.
|
|
||||||
// User.find(post.userId, function(err, user) {
|
|
||||||
// User.create(function(err, voidUser) {
|
|
||||||
// Post.create({userId: user.id}, function() {
|
|
||||||
|
|
||||||
// // There can't be any concurrency because we are counting requests
|
// There can't be any concurrency because we are counting requests
|
||||||
// // We are first testing cases when user has posts
|
// We are first testing cases when user has posts
|
||||||
// user.posts(function(err, data) {
|
user.posts(function(err, data) {
|
||||||
// var nbInitialRequests = nbSchemaRequests;
|
var nbInitialRequests = nbSchemaRequests;
|
||||||
// user.posts(function(err, data2) {
|
user.posts(function(err, data2) {
|
||||||
// test.equal(data.length, 2, 'There should be 2 posts.');
|
test.equal(data.length, 2, 'There should be 2 posts.');
|
||||||
// test.equal(data.length, data2.length, 'Posts should be the same, since we are loading on the same object.');
|
test.equal(data.length, data2.length, 'Posts should be the same, since we are loading on the same object.');
|
||||||
// requestsAreCounted && test.equal(nbInitialRequests, nbSchemaRequests, 'There should not be any request because value is cached.');
|
requestsAreCounted && test.equal(nbInitialRequests, nbSchemaRequests, 'There should not be any request because value is cached.');
|
||||||
|
|
||||||
// if (schema.name === 'mongodb') { // for the moment mongodb doesn\'t support additional conditions on hasMany relations (see above)
|
if (schema.name === 'mongodb') { // for the moment mongodb doesn\'t support additional conditions on hasMany relations (see above)
|
||||||
// test.done();
|
test.done();
|
||||||
// } else {
|
} else {
|
||||||
// user.posts({where: {id: data[0].id}}, function(err, data) {
|
user.posts({where: {id: data[0].id}}, function(err, data) {
|
||||||
// test.equal(data.length, 1, 'There should be only one post.');
|
test.equal(data.length, 1, 'There should be only one post.');
|
||||||
// requestsAreCounted && test.equal(nbInitialRequests + 1, nbSchemaRequests, 'There should be one additional request since we added conditions.');
|
requestsAreCounted && test.equal(nbInitialRequests + 1, nbSchemaRequests, 'There should be one additional request since we added conditions.');
|
||||||
|
|
||||||
// user.posts(function(err, data) {
|
user.posts(function(err, data) {
|
||||||
// test.equal(data.length, 2, 'Previous get shouldn\'t have changed cached value though, since there was additional conditions.');
|
test.equal(data.length, 2, 'Previous get shouldn\'t have changed cached value though, since there was additional conditions.');
|
||||||
// requestsAreCounted && test.equal(nbInitialRequests + 1, nbSchemaRequests, 'There should not be any request because value is cached.');
|
requestsAreCounted && test.equal(nbInitialRequests + 1, nbSchemaRequests, 'There should not be any request because value is cached.');
|
||||||
|
|
||||||
// // We are now testing cases when user doesn't have any post
|
// We are now testing cases when user doesn't have any post
|
||||||
// voidUser.posts(function(err, data) {
|
voidUser.posts(function(err, data) {
|
||||||
// var nbInitialRequests = nbSchemaRequests;
|
var nbInitialRequests = nbSchemaRequests;
|
||||||
// voidUser.posts(function(err, data2) {
|
voidUser.posts(function(err, data2) {
|
||||||
// test.equal(data.length, 0, 'There shouldn\'t be any posts (1/2).');
|
test.equal(data.length, 0, 'There shouldn\'t be any posts (1/2).');
|
||||||
// test.equal(data2.length, 0, 'There shouldn\'t be any posts (2/2).');
|
test.equal(data2.length, 0, 'There shouldn\'t be any posts (2/2).');
|
||||||
// requestsAreCounted && test.equal(nbInitialRequests, nbSchemaRequests, 'There should not be any request because value is cached.');
|
requestsAreCounted && test.equal(nbInitialRequests, nbSchemaRequests, 'There should not be any request because value is cached.');
|
||||||
|
|
||||||
// voidUser.posts(true, function(err, data3) {
|
voidUser.posts(true, function(err, data3) {
|
||||||
// test.equal(data3.length, 0, 'There shouldn\'t be any posts.');
|
test.equal(data3.length, 0, 'There shouldn\'t be any posts.');
|
||||||
// requestsAreCounted && test.equal(nbInitialRequests + 1, nbSchemaRequests, 'There should be one additional request since we forced refresh.');
|
requestsAreCounted && test.equal(nbInitialRequests + 1, nbSchemaRequests, 'There should be one additional request since we forced refresh.');
|
||||||
|
|
||||||
// test.done();
|
test.done();
|
||||||
// });
|
});
|
||||||
// });
|
});
|
||||||
// });
|
});
|
||||||
|
|
||||||
// });
|
});
|
||||||
// });
|
});
|
||||||
// }
|
}
|
||||||
|
|
||||||
// });
|
});
|
||||||
// });
|
});
|
||||||
|
|
||||||
// });
|
});
|
||||||
// });
|
});
|
||||||
// });
|
});
|
||||||
// break;
|
break;
|
||||||
// }
|
}
|
||||||
// }
|
}
|
||||||
// });
|
});
|
||||||
|
|
||||||
// });
|
});
|
||||||
|
|
||||||
// it('should handle hasOne relationship', function (test) {
|
// it('should handle hasOne relationship', function (test) {
|
||||||
// User.create(function (err, u) {
|
// User.create(function (err, u) {
|
||||||
|
|
Loading…
Reference in New Issue