Skip to content

Commit

Permalink
fix(onboarding): users can now onboard on cosmos nosql databases (#648)
Browse files Browse the repository at this point in the history
  • Loading branch information
SteveBunlon authored Nov 16, 2023
1 parent 91958c1 commit d67c5e2
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ class MongoCollectionsAnalyzer {
if (err) {
if (
err.message &&
(err.message.startsWith('CMD_NOT_ALLOWED') || err.message.startsWith('MapReduce'))
(err.message.startsWith('CMD_NOT_ALLOWED') || /mapreduce/gim.test(err.message))
) {
return resolve(MAP_REDUCE_ERROR_STRING);
}
Expand Down
20 changes: 20 additions & 0 deletions test/services/analyzer/mongo-collections-analyzer.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -1206,6 +1206,26 @@ describe('services > mongoCollectionsAnalyzer', () => {
});
});

describe('when there is a message containing mapReduce', () => {
it('should resolve an error and display a log', async () => {
expect.assertions(2);

const analyzer = new MongoCollectionsAnalyzer(makeContext());

const resolve = jest.fn();
const reject = jest.fn();

const callback = analyzer.mapReduceErrors(resolve, reject);

// Cosmos db from Azure error message
const error = { message: 'MongoError: Command mapReduce not supported.' };
callback(error, null);

expect(resolve).toHaveBeenCalledTimes(1);
expect(resolve).toHaveBeenLastCalledWith('MapReduceError');
});
});

describe('when there is "CommandNotSupportedOnView" codeName', () => {
it('should resolve an error', async () => {
expect.assertions(2);
Expand Down

0 comments on commit d67c5e2

Please sign in to comment.