Skip to content

Commit d67c5e2

Browse files
authored
fix(onboarding): users can now onboard on cosmos nosql databases (#648)
1 parent 91958c1 commit d67c5e2

File tree

2 files changed

+21
-1
lines changed

2 files changed

+21
-1
lines changed

src/services/schema/update/analyzer/mongo-collections-analyzer.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ class MongoCollectionsAnalyzer {
186186
if (err) {
187187
if (
188188
err.message &&
189-
(err.message.startsWith('CMD_NOT_ALLOWED') || err.message.startsWith('MapReduce'))
189+
(err.message.startsWith('CMD_NOT_ALLOWED') || /mapreduce/gim.test(err.message))
190190
) {
191191
return resolve(MAP_REDUCE_ERROR_STRING);
192192
}

test/services/analyzer/mongo-collections-analyzer.test.js

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1206,6 +1206,26 @@ describe('services > mongoCollectionsAnalyzer', () => {
12061206
});
12071207
});
12081208

1209+
describe('when there is a message containing mapReduce', () => {
1210+
it('should resolve an error and display a log', async () => {
1211+
expect.assertions(2);
1212+
1213+
const analyzer = new MongoCollectionsAnalyzer(makeContext());
1214+
1215+
const resolve = jest.fn();
1216+
const reject = jest.fn();
1217+
1218+
const callback = analyzer.mapReduceErrors(resolve, reject);
1219+
1220+
// Cosmos db from Azure error message
1221+
const error = { message: 'MongoError: Command mapReduce not supported.' };
1222+
callback(error, null);
1223+
1224+
expect(resolve).toHaveBeenCalledTimes(1);
1225+
expect(resolve).toHaveBeenLastCalledWith('MapReduceError');
1226+
});
1227+
});
1228+
12091229
describe('when there is "CommandNotSupportedOnView" codeName', () => {
12101230
it('should resolve an error', async () => {
12111231
expect.assertions(2);

0 commit comments

Comments
 (0)