mirror of
https://github.com/lowdefy/lowdefy.git
synced 2025-02-17 14:30:34 +08:00
fix(connection-mongodb): Fix mongodb tests.
This commit is contained in:
parent
c0dd06c19b
commit
f1d11f05a2
@ -1,5 +1,3 @@
|
||||
console.log('CWD', process.cwd());
|
||||
|
||||
module.exports = {
|
||||
clearMocks: true,
|
||||
collectCoverage: true,
|
||||
|
@ -210,14 +210,18 @@ test('$merge is not allowed with write false', async () => {
|
||||
);
|
||||
});
|
||||
|
||||
test('$merge is allowed with write true', async () => {
|
||||
const request = { pipeline: [{ $merge: { into: 'mergeCollection' } }] };
|
||||
const connection = {
|
||||
databaseUri,
|
||||
databaseName,
|
||||
collection,
|
||||
write: true,
|
||||
};
|
||||
const res = await resolver({ request, connection });
|
||||
expect(res).toEqual([]);
|
||||
});
|
||||
// TODO:
|
||||
// MongoDB version cannot be configured to a version that supports $merge due to
|
||||
// https://github.com/shelfio/jest-mongodb/issues/311
|
||||
|
||||
// test('$merge is allowed with write true', async () => {
|
||||
// const request = { pipeline: [{ $merge: { into: 'mergeCollection' } }] };
|
||||
// const connection = {
|
||||
// databaseUri,
|
||||
// databaseName,
|
||||
// collection,
|
||||
// write: true,
|
||||
// };
|
||||
// const res = await resolver({ request, connection });
|
||||
// expect(res).toEqual([]);
|
||||
// });
|
||||
|
@ -110,7 +110,7 @@ test('deleteMany mongodb error', async () => {
|
||||
write: true,
|
||||
};
|
||||
await expect(resolver({ request, connection })).rejects.toThrow(
|
||||
"BSON field 'writeConcern.w' is the wrong type 'bool', expected types '[string, int, decimal, double, long']"
|
||||
'w has to be a number or a string'
|
||||
);
|
||||
});
|
||||
|
||||
|
@ -78,7 +78,7 @@ test('deleteOne catch invalid options', async () => {
|
||||
write: true,
|
||||
};
|
||||
await expect(resolver({ request, connection })).rejects.toThrow(
|
||||
"BSON field 'writeConcern.w' is the wrong type 'bool', expected types '[string, int, decimal, double, long']"
|
||||
'w has to be a number or a string'
|
||||
);
|
||||
});
|
||||
|
||||
|
@ -100,9 +100,7 @@ test('insertMany mongodb error', async () => {
|
||||
write: true,
|
||||
};
|
||||
await resolver({ request, connection });
|
||||
await expect(resolver({ request, connection })).rejects.toThrow(
|
||||
'E11000 duplicate key error collection: test.insertMany index: _id_ dup key: { _id: "insertMany9-1" }'
|
||||
);
|
||||
await expect(resolver({ request, connection })).rejects.toThrow('E11000 duplicate key error');
|
||||
});
|
||||
|
||||
test('checkRead should be false', async () => {
|
||||
|
@ -92,9 +92,7 @@ test('insertOne mongodb error', async () => {
|
||||
write: true,
|
||||
};
|
||||
await resolver({ request, connection });
|
||||
await expect(resolver({ request, connection })).rejects.toThrow(
|
||||
'E11000 duplicate key error collection: test.insertOne index: _id_ dup key: { _id: "insertOne_mongodb_error" }'
|
||||
);
|
||||
await expect(resolver({ request, connection })).rejects.toThrow('E11000 duplicate key error');
|
||||
});
|
||||
|
||||
test('checkRead should be false', async () => {
|
||||
|
Loading…
Reference in New Issue
Block a user