|
| 1 | +var Buffer = require('buffer').Buffer; |
| 2 | + |
| 3 | +exports['should correctly honor promoteBuffers when creating an instance using Db'] = { |
| 4 | + // Add a tag that our runner can trigger on |
| 5 | + // in this case we are setting that node needs to be higher than 0.10.X to run |
| 6 | + metadata: { requires: { topology: ['single', 'replicaset', 'sharded', 'ssl', 'heap', 'wiredtiger'] } }, |
| 7 | + |
| 8 | + // The actual test we wish to run |
| 9 | + test: function(configuration, test) { |
| 10 | + var Long = configuration.require.Long, |
| 11 | + Int32 = configuration.require.Int32, |
| 12 | + Double = configuration.require.Double; |
| 13 | + |
| 14 | + var o = configuration.writeConcernMax(); |
| 15 | + var db = configuration.newDbInstance(o, {native_parser:true, promoteBuffers: true}) |
| 16 | + db.open(function(err, db) { |
| 17 | + db.collection('shouldCorrectlyHonorPromoteBuffer1').insert({ |
| 18 | + doc: new Buffer(256) |
| 19 | + }, function(err, doc) { |
| 20 | + test.equal(null, err); |
| 21 | + |
| 22 | + db.collection('shouldCorrectlyHonorPromoteBuffer1').findOne(function(err, doc) { |
| 23 | + test.equal(null, err); |
| 24 | + test.ok(doc.doc instanceof Buffer); |
| 25 | + |
| 26 | + db.close(); |
| 27 | + test.done(); |
| 28 | + }); |
| 29 | + }); |
| 30 | + }); |
| 31 | + } |
| 32 | +} |
| 33 | + |
| 34 | +exports['should correctly honor promoteValues when creating an instance using MongoClient'] = { |
| 35 | + // Add a tag that our runner can trigger on |
| 36 | + // in this case we are setting that node needs to be higher than 0.10.X to run |
| 37 | + metadata: { requires: { topology: ['single', 'replicaset', 'sharded', 'ssl', 'heap', 'wiredtiger'] } }, |
| 38 | + |
| 39 | + // The actual test we wish to run |
| 40 | + test: function(configuration, test) { |
| 41 | + var Long = configuration.require.Long, |
| 42 | + Int32 = configuration.require.Int32, |
| 43 | + Double = configuration.require.Double, |
| 44 | + MongoClient = configuration.require.MongoClient; |
| 45 | + |
| 46 | + MongoClient.connect(configuration.url(), { |
| 47 | + promoteBuffers: true, |
| 48 | + }, function(err, db) { |
| 49 | + db.collection('shouldCorrectlyHonorPromoteValues2').insert({ |
| 50 | + doc: new Buffer(256) |
| 51 | + }, function(err, doc) { |
| 52 | + test.equal(null, err); |
| 53 | + |
| 54 | + db.collection('shouldCorrectlyHonorPromoteValues2').findOne(function(err, doc) { |
| 55 | + test.equal(null, err); |
| 56 | + test.ok(doc.doc instanceof Buffer); |
| 57 | + |
| 58 | + db.close(); |
| 59 | + test.done(); |
| 60 | + }); |
| 61 | + }); |
| 62 | + }); |
| 63 | + } |
| 64 | +} |
| 65 | + |
| 66 | +exports['should correctly honor promoteValues at cursor level'] = { |
| 67 | + // Add a tag that our runner can trigger on |
| 68 | + // in this case we are setting that node needs to be higher than 0.10.X to run |
| 69 | + metadata: { requires: { topology: ['single', 'replicaset', 'sharded', 'ssl', 'heap', 'wiredtiger'] } }, |
| 70 | + |
| 71 | + // The actual test we wish to run |
| 72 | + test: function(configuration, test) { |
| 73 | + var Long = configuration.require.Long, |
| 74 | + Int32 = configuration.require.Int32, |
| 75 | + Double = configuration.require.Double, |
| 76 | + MongoClient = configuration.require.MongoClient; |
| 77 | + |
| 78 | + MongoClient.connect(configuration.url(), { |
| 79 | + promoteBuffers: true, |
| 80 | + }, function(err, db) { |
| 81 | + db.collection('shouldCorrectlyHonorPromoteValues3').insert({ |
| 82 | + doc: new Buffer(256) |
| 83 | + }, function(err, doc) { |
| 84 | + test.equal(null, err); |
| 85 | + |
| 86 | + db.collection('shouldCorrectlyHonorPromoteValues3').find().next(function(err, doc) { |
| 87 | + test.equal(null, err); |
| 88 | + test.ok(doc.doc instanceof Buffer); |
| 89 | + |
| 90 | + db.close(); |
| 91 | + test.done(); |
| 92 | + }); |
| 93 | + }); |
| 94 | + }); |
| 95 | + } |
| 96 | +} |
| 97 | + |
| 98 | +exports['should correctly honor promoteValues at cursor find level'] = { |
| 99 | + // Add a tag that our runner can trigger on |
| 100 | + // in this case we are setting that node needs to be higher than 0.10.X to run |
| 101 | + metadata: { requires: { topology: ['single', 'replicaset', 'sharded', 'ssl', 'heap', 'wiredtiger'] } }, |
| 102 | + |
| 103 | + // The actual test we wish to run |
| 104 | + test: function(configuration, test) { |
| 105 | + var Long = configuration.require.Long, |
| 106 | + Int32 = configuration.require.Int32, |
| 107 | + Double = configuration.require.Double, |
| 108 | + MongoClient = configuration.require.MongoClient; |
| 109 | + |
| 110 | + MongoClient.connect(configuration.url(), { |
| 111 | + }, function(err, db) { |
| 112 | + db.collection('shouldCorrectlyHonorPromoteValues4').insert({ |
| 113 | + doc: new Buffer(256) |
| 114 | + }, function(err, doc) { |
| 115 | + test.equal(null, err); |
| 116 | + |
| 117 | + db.collection('shouldCorrectlyHonorPromoteValues4').find({}, {}, {promoteBuffers: true}).next(function(err, doc) { |
| 118 | + test.equal(null, err); |
| 119 | + test.ok(doc.doc instanceof Buffer); |
| 120 | + |
| 121 | + db.close(); |
| 122 | + test.done(); |
| 123 | + }); |
| 124 | + }); |
| 125 | + }); |
| 126 | + } |
| 127 | +} |
| 128 | + |
| 129 | +exports['should correctly honor promoteValues at aggregate level'] = { |
| 130 | + // Add a tag that our runner can trigger on |
| 131 | + // in this case we are setting that node needs to be higher than 0.10.X to run |
| 132 | + metadata: { requires: { topology: ['single', 'replicaset', 'sharded', 'ssl', 'heap', 'wiredtiger'] } }, |
| 133 | + |
| 134 | + // The actual test we wish to run |
| 135 | + test: function(configuration, test) { |
| 136 | + var Long = configuration.require.Long, |
| 137 | + Int32 = configuration.require.Int32, |
| 138 | + Double = configuration.require.Double, |
| 139 | + MongoClient = configuration.require.MongoClient; |
| 140 | + |
| 141 | + MongoClient.connect(configuration.url(), { |
| 142 | + }, function(err, db) { |
| 143 | + db.collection('shouldCorrectlyHonorPromoteValues5').insert({ |
| 144 | + doc: new Buffer(256) |
| 145 | + }, function(err, doc) { |
| 146 | + test.equal(null, err); |
| 147 | + |
| 148 | + db.collection('shouldCorrectlyHonorPromoteValues5').aggregate([{$match: {}}], {promoteBuffers: true}).next(function(err, doc) { |
| 149 | + test.equal(null, err); |
| 150 | + test.ok(doc.doc instanceof Buffer); |
| 151 | + |
| 152 | + db.close(); |
| 153 | + test.done(); |
| 154 | + }); |
| 155 | + }); |
| 156 | + }); |
| 157 | + } |
| 158 | +} |
0 commit comments