mirror of
https://github.com/meteor/meteor.git
synced 2026-05-02 03:01:46 -04:00
- fix test: 'mongo-livedata - oplog - include selector fields'
This commit is contained in:
@@ -3495,47 +3495,53 @@ Meteor.isServer &&
|
||||
await observeWithoutOplog.stop();
|
||||
});
|
||||
|
||||
Meteor.isServer && Tinytest.add("mongo-livedata - oplog - include selector fields", function (test) {
|
||||
var collName = "includeSelector" + Random.id();
|
||||
var coll = new Mongo.Collection(collName);
|
||||
Meteor.isServer &&
|
||||
Tinytest.addAsync(
|
||||
'mongo-livedata - oplog - include selector fields',
|
||||
async function(test) {
|
||||
var collName = 'includeSelector' + Random.id();
|
||||
var coll = new Mongo.Collection(collName);
|
||||
|
||||
var docId = coll.insert({a: 1, b: [3, 2], c: 'foo'});
|
||||
test.isTrue(docId);
|
||||
var docId = await coll.insertAsync({ a: 1, b: [3, 2], c: 'foo' });
|
||||
test.isTrue(docId);
|
||||
|
||||
// Wait until we've processed the insert oplog entry. (If the insert shows up
|
||||
// during the observeChanges, the bug in question is not consistently
|
||||
// reproduced.) We don't have to do this for polling observe (eg
|
||||
// --disable-oplog).
|
||||
waitUntilOplogCaughtUp();
|
||||
// Wait until we've processed the insert oplog entry. (If the insert shows up
|
||||
// during the observeChanges, the bug in question is not consistently
|
||||
// reproduced.) We don't have to do this for polling observe (eg
|
||||
// --disable-oplog).
|
||||
await waitUntilOplogCaughtUp();
|
||||
|
||||
var output = [];
|
||||
var handle = coll.find({a: 1, b: 2}, {fields: {c: 1}}).observeChanges({
|
||||
added: function (id, fields) {
|
||||
output.push(['added', id, fields]);
|
||||
},
|
||||
changed: function (id, fields) {
|
||||
output.push(['changed', id, fields]);
|
||||
},
|
||||
removed: function (id) {
|
||||
output.push(['removed', id]);
|
||||
var output = [];
|
||||
var handle = await coll
|
||||
.find({ a: 1, b: 2 }, { fields: { c: 1 } })
|
||||
.observeChanges({
|
||||
added: function(id, fields) {
|
||||
output.push(['added', id, fields]);
|
||||
},
|
||||
changed: function(id, fields) {
|
||||
output.push(['changed', id, fields]);
|
||||
},
|
||||
removed: function(id) {
|
||||
output.push(['removed', id]);
|
||||
},
|
||||
});
|
||||
// Initially should match the document.
|
||||
test.length(output, 1);
|
||||
test.equal(output.shift(), ['added', docId, { c: 'foo' }]);
|
||||
|
||||
// Update in such a way that, if we only knew about the published field 'c'
|
||||
// and the changed field 'b' (but not the field 'a'), we would think it didn't
|
||||
// match any more. (This is a regression test for a bug that existed because
|
||||
// we used to not use the shared projection in the initial query.)
|
||||
await runInFence(async function() {
|
||||
await coll.updateAsync(docId, { $set: { 'b.0': 2, c: 'bar' } });
|
||||
});
|
||||
test.length(output, 1);
|
||||
test.equal(output.shift(), ['changed', docId, { c: 'bar' }]);
|
||||
|
||||
handle.stop();
|
||||
}
|
||||
});
|
||||
// Initially should match the document.
|
||||
test.length(output, 1);
|
||||
test.equal(output.shift(), ['added', docId, {c: 'foo'}]);
|
||||
|
||||
// Update in such a way that, if we only knew about the published field 'c'
|
||||
// and the changed field 'b' (but not the field 'a'), we would think it didn't
|
||||
// match any more. (This is a regression test for a bug that existed because
|
||||
// we used to not use the shared projection in the initial query.)
|
||||
runInFence(function () {
|
||||
coll.update(docId, {$set: {'b.0': 2, c: 'bar'}});
|
||||
});
|
||||
test.length(output, 1);
|
||||
test.equal(output.shift(), ['changed', docId, {c: 'bar'}]);
|
||||
|
||||
handle.stop();
|
||||
});
|
||||
);
|
||||
|
||||
Meteor.isServer && Tinytest.add("mongo-livedata - oplog - transform", function (test) {
|
||||
var collName = "oplogTransform" + Random.id();
|
||||
|
||||
Reference in New Issue
Block a user