@natlibfi/melinda-rest-api-commons 4.2.3 → 4.2.4-alpha.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (47) hide show
  1. package/.github/workflows/melinda-node-tests.yml +1 -1
  2. package/dist/amqp.js +2 -2
  3. package/dist/amqp.js.map +1 -1
  4. package/dist/index.js +1 -1
  5. package/dist/index.js.map +1 -1
  6. package/dist/mongo.js +158 -80
  7. package/dist/mongo.js.map +1 -1
  8. package/dist/mongoLog.js +1 -4
  9. package/dist/mongoLog.js.map +1 -1
  10. package/package.json +26 -24
  11. package/{dist → tests}/amqp.health.spec.js +17 -10
  12. package/tests/amqp.tests.spec.js +301 -0
  13. package/tests/helpers/conversion.spec.js +95 -0
  14. package/tests/helpers/fix.spec.js +41 -0
  15. package/tests/helpers/validation.spec.js +58 -0
  16. package/tests/mongo-add-blob-size.spec.js +100 -0
  17. package/tests/mongo-check-and-check-state.spec.js +112 -0
  18. package/tests/mongo-check-and-set-import-job-state.spec.js +112 -0
  19. package/tests/mongo-check-timeout.spec.js +111 -0
  20. package/tests/mongo-create-bulk.spec.js +100 -0
  21. package/tests/mongo-create-prio.spec.js +98 -0
  22. package/tests/mongo-get-one.spec.js +103 -0
  23. package/tests/mongo-get-stream.spec.js +120 -0
  24. package/tests/mongo-push-ids.spec.js +101 -0
  25. package/tests/mongo-push-messages.spec.js +99 -0
  26. package/tests/mongo-query-by-id.spec.js +112 -0
  27. package/tests/mongo-query.spec.js +108 -0
  28. package/tests/mongo-read-content.spec.js +123 -0
  29. package/tests/mongo-remove.spec.js +115 -0
  30. package/tests/mongo-set-blob-size.spec.js +99 -0
  31. package/tests/mongo-set-import-job-state.spec.js +102 -0
  32. package/tests/mongo-set-operation.spec.js +102 -0
  33. package/tests/mongo-set-operations.spec.js +101 -0
  34. package/tests/mongo-set-state.spec.js +102 -0
  35. package/{dist → tests}/mongoLog.spec.js +22 -22
  36. package/tests/testUtils.js +94 -0
  37. package/dist/amqp.health.spec.js.map +0 -1
  38. package/dist/amqp.tests.spec.js +0 -310
  39. package/dist/amqp.tests.spec.js.map +0 -1
  40. package/dist/helpers/conversion.spec.js +0 -88
  41. package/dist/helpers/conversion.spec.js.map +0 -1
  42. package/dist/helpers/fix.spec.js +0 -46
  43. package/dist/helpers/fix.spec.js.map +0 -1
  44. package/dist/helpers/validation.spec.js +0 -47
  45. package/dist/helpers/validation.spec.js.map +0 -1
  46. package/dist/mongo.spec.js.draft +0 -54
  47. package/dist/mongoLog.spec.js.map +0 -1
@@ -0,0 +1,301 @@
1
+ import {expect} from 'chai';
2
+ import {READERS} from '@natlibfi/fixura';
3
+ import createDebugLogger from 'debug';
4
+ import generateTests from '@natlibfi/fixugen';
5
+ import {amqpFactory} from '../src/index';
6
+ import {Error as ApiError} from '@natlibfi/melinda-commons';
7
+ import {promisify} from 'util';
8
+
9
+ const setTimeoutPromise = promisify(setTimeout);
10
+ const debug = createDebugLogger('@natlibfi/melinda-rest-api-commons:amqp:test');
11
+ //const debugData = debug.extend('data');
12
+
13
+ const testData = {
14
+ queue: 'TESTQUEUE',
15
+ correlationId: 'aaaaaaaa-0000-aaaa-0000-000000000000',
16
+ data: {'leader': '02518cam a2200745zi 4500', 'fields': [{'tag': '001', 'value': '000019640'}]}
17
+ };
18
+
19
+ debug(`Testing amqp against a local AMQP instance - we'll need some kind of mockup for this`);
20
+ const amqpUrl = 'amqp://127.0.0.1:5672/';
21
+ // eslint-disable-next-line functional/no-let
22
+ let amqpOperator;
23
+
24
+ generateTests({
25
+ callback,
26
+ path: [__dirname, '..', 'test-fixtures', 'amqp'],
27
+ recurse: false,
28
+ useMetadataFile: true,
29
+ fixura: {
30
+ failWhenNotFound: true,
31
+ reader: READERS.JSON
32
+ },
33
+ mocha: {
34
+ before: async () => {
35
+ debug(`Connecting to ${amqpUrl}, with healthCheck running`);
36
+ amqpOperator = await amqpFactory(amqpUrl, true);
37
+ },
38
+ beforeEach: async () => {
39
+ await amqpOperator.checkQueue({queue: testData.queue, toRecord: false, purge: true});
40
+ },
41
+ afterEach: async () => {
42
+ await amqpOperator.removeQueue(testData.queue);
43
+ },
44
+ after: async () => {
45
+ await amqpOperator.closeConnection();
46
+ //await testHeathCheck();
47
+ }
48
+ }
49
+ });
50
+
51
+ // eslint-disable-next-line max-statements
52
+ async function callback({
53
+ getFixture,
54
+ expectToFail = false,
55
+ expectedErrorStatus = '',
56
+ ackMessages = false,
57
+ nackMessages = false,
58
+ checkNextMessage = false,
59
+ checkQueueStyle = false,
60
+ queue = testData.queue,
61
+ sentToQueue,
62
+ expectedMessageCount,
63
+ removeQueue = false,
64
+ expectedErrorMessage = undefined,
65
+ expectApiError = false,
66
+ expectFalseCheckResult = false
67
+ }) {
68
+ try {
69
+ await sendMessagesToQueue();
70
+
71
+ await ackOrNackMessages();
72
+
73
+ await checkQueue();
74
+
75
+ await queueRemoval();
76
+
77
+ const messageCount = await amqpOperator.checkQueue({queue, style: 'messages'});
78
+ debug(`MessageCount: ${messageCount}`);
79
+ expect(messageCount).to.eql(expectedMessageCount);
80
+
81
+ if (checkNextMessage) {
82
+ const {headers, records} = await queueCheckNextMessage();
83
+ const nextMessage = {headers, records};
84
+ const expectedNextMessage = getFixture('expectedMessage.json');
85
+ expect(nextMessage).to.eql(expectedNextMessage);
86
+ return;
87
+ }
88
+
89
+ } catch (error) {
90
+ if (!expectToFail) {
91
+ throw error;
92
+ }
93
+ expect(expectToFail, 'This is expected to fail').to.equal(true);
94
+ testErrors(error);
95
+ }
96
+
97
+ function testErrors(error) {
98
+
99
+ if (expectApiError) {
100
+ expect(error).to.be.instanceOf(ApiError);
101
+ debug(`We expected and got an ApiError`);
102
+ expect(error.status).to.equal(expectedErrorStatus);
103
+
104
+ if (expectedErrorMessage) {
105
+ expect(error.payload).to.eql(expectedErrorMessage);
106
+ return;
107
+ }
108
+
109
+ return;
110
+ }
111
+ expect(error).not.to.be.instanceOf(ApiError);
112
+ debug(`We expected and got an non-ApiError`);
113
+ debug(`Error is a ${error.constructor.name}`);
114
+ }
115
+
116
+ function queueRemoval() {
117
+ if (removeQueue) {
118
+ return amqpOperator.removeQueue(removeQueue);
119
+ }
120
+
121
+ return;
122
+ }
123
+
124
+ function queueCheckNextMessage() {
125
+ if (checkNextMessage) {
126
+ return amqpOperator.consumeOne(testData.queue, true);
127
+ }
128
+
129
+ return false;
130
+ }
131
+
132
+ // eslint-disable-next-line max-statements
133
+ async function checkQueue() {
134
+ debug(`checkQueueStyle: ${checkQueueStyle}`);
135
+
136
+ if (checkQueueStyle === 'oneToRecord') {
137
+ const result = await amqpOperator.checkQueue({queue, style: 'one', toRecord: true, purge: false});
138
+
139
+ if (expectFalseCheckResult) {
140
+ expect(result).to.eql(false);
141
+ return;
142
+ }
143
+
144
+ expect(result).to.have.property('headers');
145
+ expect(result).to.have.property('records');
146
+ expect(result).to.have.property('messages');
147
+ expect(result.records.length).to.eql(1);
148
+ expect(result.messages.length).to.eql(1);
149
+
150
+ return;
151
+ }
152
+
153
+ if (checkQueueStyle === 'oneNotRecord') {
154
+ const result = await amqpOperator.checkQueue({queue, style: 'one', toRecord: false, purge: false});
155
+ const {fields} = result;
156
+
157
+ if (expectFalseCheckResult) {
158
+ expect(result).to.eql(false);
159
+ return;
160
+ }
161
+
162
+ expect(fields).to.have.property('deliveryTag');
163
+ expect(fields).to.have.property('exchange');
164
+ expect(fields).to.have.property('messageCount');
165
+ expect(fields).to.have.property('redelivered');
166
+ expect(fields).to.have.property('routingKey');
167
+ expect(typeof fields.deliveryTag).to.be.eql('number');
168
+ expect(typeof fields.messageCount).to.be.eql('number');
169
+ expect(typeof fields.redelivered).to.be.eql('boolean');
170
+ expect(typeof fields.routingKey).to.be.eql('string');
171
+
172
+ return;
173
+ }
174
+
175
+ if (checkQueueStyle === 'basicToRecord') {
176
+ const result = await amqpOperator.checkQueue({queue, style: 'basic', toRecord: true, purge: false});
177
+
178
+ if (expectFalseCheckResult) {
179
+ expect(result).to.eql(false);
180
+ return;
181
+ }
182
+
183
+ expect(result).to.have.property('headers');
184
+ expect(result).to.have.property('records');
185
+ expect(result).to.have.property('messages');
186
+ expect(result.records.length).to.eql(3);
187
+ expect(result.messages.length).to.eql(3);
188
+ const expectedResult = getFixture('expectedResult.json');
189
+ expect(result.records).to.eql(expectedResult);
190
+
191
+ return;
192
+ }
193
+
194
+ if (checkQueueStyle === 'basicNotRecord') {
195
+ const result = await amqpOperator.checkQueue({queue, style: 'basic', toRecord: false, purge: false});
196
+
197
+ if (expectFalseCheckResult) {
198
+ expect(result).to.eql(false);
199
+ return;
200
+ }
201
+
202
+ expect(result).to.have.property('headers');
203
+ expect(result).to.have.property('messages');
204
+ expect(result.messages.length).to.eql(3);
205
+
206
+ const [{fields}] = result.messages;
207
+
208
+ expect(fields).to.have.property('deliveryTag');
209
+ expect(fields).to.have.property('exchange');
210
+ expect(fields).to.have.property('messageCount');
211
+ expect(fields).to.have.property('redelivered');
212
+ expect(fields).to.have.property('routingKey');
213
+
214
+ expect(typeof fields.deliveryTag).to.be.eql('number');
215
+ expect(typeof fields.messageCount).to.be.eql('number');
216
+ expect(typeof fields.redelivered).to.be.eql('boolean');
217
+ expect(typeof fields.routingKey).to.be.eql('string');
218
+
219
+ return;
220
+ }
221
+
222
+ if (checkQueueStyle === 'purge') {
223
+ return amqpOperator.checkQueue({queue, style: 'messages', purge: true});
224
+ }
225
+
226
+ if (checkQueueStyle === 'foobar') {
227
+ return amqpOperator.checkQueue({queue, style: 'foobar', toRecord: false, purge: false});
228
+ }
229
+
230
+ return false;
231
+ }
232
+
233
+ async function ackOrNackMessages() {
234
+ if (ackMessages) {
235
+ const message = await amqpOperator.consumeOne(testData.queue, false);
236
+ await amqpOperator.ackMessages([message]);
237
+
238
+ return setTimeoutPromise(10);
239
+ }
240
+
241
+ if (nackMessages) {
242
+ const message = await amqpOperator.consumeOne(testData.queue, false);
243
+ await amqpOperator.nackMessages([message]);
244
+
245
+ return setTimeoutPromise(10);
246
+ }
247
+
248
+ return;
249
+ }
250
+
251
+ async function sendMessagesToQueue() {
252
+ if (sentToQueue) {
253
+ const messages = getFixture('input.json');
254
+ // {queue, correlationId, headers, data}
255
+
256
+ const promises = messages.map(message => amqpOperator.sendToQueue(message));
257
+ await Promise.all(promises);
258
+
259
+ return setTimeoutPromise(10);
260
+ }
261
+
262
+ return;
263
+ }
264
+ }
265
+
266
+ /*
267
+ function testHeathCheck() {
268
+ return it('expects healthCheck', async () => {
269
+
270
+ const amqpOperator2 = await amqpFactory(amqpUrl, true);
271
+ try {
272
+
273
+ debug(`**********`);
274
+ await testHealthCheckLoopWorking(amqpOperator2);
275
+
276
+ debug(`**********`);
277
+ await testHealthCheckLoopErroring(amqpOperator2);
278
+ } catch (error) {
279
+ debug(error);
280
+ expect(error).to.eql('');
281
+ } finally {
282
+ amqpOperator2.closeConnection();
283
+ }
284
+
285
+ async function testHealthCheckLoopWorking(amqpOperator) {
286
+ debug(`Testing healthCheckLoop for ${amqpOperator}`);
287
+ debug(`Waiting 0.5s and expecting healthCheckLoop to work`);
288
+ await setTimeoutPromise('500');
289
+ debug(`Amqp Operator should have been alive.`);
290
+ }
291
+
292
+ async function testHealthCheckLoopErroring(amqpOperator) {
293
+ debug(`Testing healthCheckLoop with closed channel`);
294
+ amqpOperator.closeChannel();
295
+ debug(`Waiting 0.5s and expecting healthCheckLoop to throw error`);
296
+ await setTimeoutPromise('500');
297
+ debug(`amqpOperator should have errored`);
298
+ }
299
+ });
300
+ }
301
+ */
@@ -0,0 +1,95 @@
1
+
2
+
3
+ import {expect} from 'chai';
4
+ import fixtureFactory from '@natlibfi/fixura';
5
+ import {MarcRecord} from '@natlibfi/marc-record';
6
+ import {Error as ConversionError} from '@natlibfi/melinda-commons';
7
+ import createConversionService from '../../src/helpers/conversion';
8
+ import {CONVERSION_FORMATS} from '../../src/constants';
9
+
10
+ describe('services/conversion', () => {
11
+ const {getFixture} = fixtureFactory({root: [
12
+ __dirname,
13
+ '..',
14
+ '..',
15
+ 'test-fixtures',
16
+ 'conversion'
17
+ ]});
18
+ const conversionService = createConversionService();
19
+
20
+ const marcRecord = new MarcRecord(JSON.parse(getFixture({components: ['json1']})), {subfieldValues: false});
21
+ const marcXml = getFixture({components: ['marcxml1']});
22
+ const iso2709 = getFixture({components: ['iso2709_1']});
23
+ const json = getFixture({components: ['json1']});
24
+ const alephSeq = getFixture({components: ['aleph_sequential']});
25
+
26
+
27
+ describe('factory', () => {
28
+ it('Should create the expected object', () => {
29
+ const service = createConversionService();
30
+ expect(service).to.be.an('object').and
31
+ .respondTo('serialize')
32
+ .respondTo('unserialize');
33
+ });
34
+ });
35
+
36
+ describe('#serialize', () => {
37
+ it('Should throw because of unsupported format', () => {
38
+ expect(conversionService.serialize).to.throw();
39
+ });
40
+
41
+ it('Should serialize to MARCXML', () => {
42
+ const data = conversionService.serialize(marcRecord, CONVERSION_FORMATS.MARCXML);
43
+ expect(data).to.equal(marcXml);
44
+ });
45
+
46
+ it('Should serialize to ISO2709', () => {
47
+ const data = conversionService.serialize(marcRecord, CONVERSION_FORMATS.ISO2709);
48
+ expect(data).to.equal(iso2709);
49
+ });
50
+
51
+ it('Should serialize to JSON', () => {
52
+ const data = conversionService.serialize(marcRecord, CONVERSION_FORMATS.JSON);
53
+ expect(data).to.equal(json);
54
+ });
55
+
56
+ it('Should serialize to aleph sequential', () => {
57
+ const data = conversionService.serialize(marcRecord, CONVERSION_FORMATS.ALEPHSEQ);
58
+ expect(data).to.equal(alephSeq);
59
+ });
60
+
61
+ });
62
+
63
+ describe('#unserialize', () => {
64
+ it('Should throw because of unsupported format', () => {
65
+ expect(conversionService.unserialize).to.throw();
66
+ });
67
+
68
+ it('Should unserialize from MARCXML', async () => {
69
+ const record = await conversionService.unserialize(marcXml, CONVERSION_FORMATS.MARCXML);
70
+ expect(record.equalsTo(marcRecord)).to.equal(true);
71
+ });
72
+
73
+ it('Should unserialize from ISO2709', () => {
74
+ const record = conversionService.unserialize(iso2709, CONVERSION_FORMATS.ISO2709);
75
+ expect(record.equalsTo(marcRecord)).to.equal(true);
76
+ });
77
+
78
+ it('Should unserialize from JSON', () => {
79
+ const record = conversionService.unserialize(json, CONVERSION_FORMATS.JSON);
80
+ expect(record.equalsTo(marcRecord)).to.equal(true);
81
+ });
82
+
83
+ it('Should unserialize from Aleph sequential', () => {
84
+ const record = conversionService.unserialize(alephSeq, CONVERSION_FORMATS.ALEPHSEQ);
85
+ expect(record.equalsTo(marcRecord)).to.equal(true);
86
+ });
87
+
88
+
89
+ it('Should throw because the record could not be unserialized', () => {
90
+ expect(() => {
91
+ conversionService.unserialize('', CONVERSION_FORMATS.JSON);
92
+ }).to.throw(ConversionError);
93
+ });
94
+ });
95
+ });
@@ -0,0 +1,41 @@
1
+ import {expect} from 'chai';
2
+ import {MarcRecord} from '@natlibfi/marc-record';
3
+ import {READERS} from '@natlibfi/fixura';
4
+ import generateTests from '@natlibfi/fixugen';
5
+ import {fixRecord} from '../../src/helpers/fix';
6
+ import * as fixSettings from '../../src/helpers/fix-constants';
7
+ import createDebugLogger from 'debug';
8
+ // import inspect from 'util';
9
+
10
+ const debug = createDebugLogger('@natlibfi/melinda-rest-api-commons:fix:test');
11
+ const debugData = debug.extend('data');
12
+
13
+ generateTests({
14
+ callback,
15
+ path: [__dirname, '..', '..', 'test-fixtures', 'fix'],
16
+ recurse: true,
17
+ useMetadataFile: true,
18
+ fixura: {
19
+ failWhenNotFound: false,
20
+ reader: READERS.JSON
21
+ }
22
+ });
23
+
24
+ function callback({getFixture, settings = undefined}) {
25
+ if (settings !== undefined && fixSettings[settings] === undefined) {
26
+ throw new Error(`There are no settings ${settings} defined!`);
27
+ }
28
+ const runSettings = fixSettings[settings] || settings;
29
+
30
+ const record = new MarcRecord(getFixture('record.json'), {subfieldValues: false});
31
+ const expectedRecord = getFixture('expectedRecord.json');
32
+
33
+ debug(`Running fixer with settings ${settings}.`);
34
+ debugData(JSON.stringify(runSettings, null, 2));
35
+
36
+ const resultRecord = fixRecord(record, runSettings);
37
+ debugData(`Result: ${JSON.stringify(resultRecord)}`);
38
+ debugData(`Expected: ${JSON.stringify(expectedRecord)}`);
39
+ expect(resultRecord).to.eql(expectedRecord);
40
+
41
+ }
@@ -0,0 +1,58 @@
1
+ import {expect} from 'chai';
2
+ import fixtureFactory, {READERS} from '@natlibfi/fixura';
3
+ import {MarcRecord} from '@natlibfi/marc-record';
4
+ import createValidator from '../../src/helpers/validation';
5
+
6
+ describe('services/validate', () => {
7
+ const FIXTURES_PATH = [
8
+ __dirname,
9
+ '..',
10
+ '..',
11
+ 'test-fixtures',
12
+ 'validation'
13
+ ];
14
+ const {getFixture} = fixtureFactory({root: FIXTURES_PATH, reader: READERS.JSON});
15
+
16
+ describe('f003-fi-melinda', () => {
17
+ it('Should have failed: false', async () => {
18
+ const validator = await createValidator();
19
+ const record = new MarcRecord(getFixture({
20
+ components: [
21
+ 'in',
22
+ 'f003-fi-melinda.json'
23
+ ]
24
+ }));
25
+ const result = await validator(record.toObject());
26
+ const expected = getFixture({
27
+ components: [
28
+ 'out',
29
+ 'f003-fi-melinda.json'
30
+ ]
31
+ });
32
+ expect(result).to.eql(expected);
33
+ expect(result.failed).to.equal(false);
34
+ });
35
+ });
36
+
37
+ describe('f003-not-fi-melinda', () => {
38
+ it('Should have failed: true', async () => {
39
+ const validator = await createValidator();
40
+ const record = new MarcRecord(getFixture({
41
+ components: [
42
+ 'in',
43
+ 'f003-not-fi-melinda.json'
44
+ ]
45
+ }));
46
+ const result = await validator(record.toObject());
47
+ const expected = getFixture({
48
+ components: [
49
+ 'out',
50
+ 'f003-not-fi-melinda.json'
51
+ ]
52
+ });
53
+ expect(result).to.eql(expected);
54
+ expect(result.failed).to.equal(true);
55
+ });
56
+ });
57
+ });
58
+
@@ -0,0 +1,100 @@
1
+ //import {expect} from 'chai';
2
+ import {READERS} from '@natlibfi/fixura';
3
+ import mongoFixturesFactory from '@natlibfi/fixura-mongo';
4
+ import generateTests from '@natlibfi/fixugen';
5
+ import createMongoOperator from '../src/mongo';
6
+ import createDebugLogger from 'debug';
7
+ //import {handleError, compareToFirstDbEntry, compareToDbEntry, formatQueueItem, streamToString} from './testUtils';
8
+ import {handleError, compareToFirstDbEntry} from './testUtils';
9
+
10
+
11
+ let mongoFixtures; // eslint-disable-line functional/no-let
12
+ const debug = createDebugLogger('@natlibfi/melinda-rest-api-commons/mongo:add-blob-size:test');
13
+
14
+ generateTests({
15
+ callback,
16
+ path: [__dirname, '..', 'test-fixtures', 'mongo', 'add-blob-size'],
17
+ recurse: false,
18
+ useMetadataFile: true,
19
+ fixura: {
20
+ failWhenNotFound: true,
21
+ reader: READERS.JSON
22
+ },
23
+ mocha: {
24
+ before: async () => {
25
+ //debug(`<< Before`);
26
+ await initMongofixtures();
27
+ },
28
+ beforeEach: async () => {
29
+ //debug(`<< BeforeEach`);
30
+ await mongoFixtures.clear();
31
+ },
32
+ afterEach: async () => {
33
+ //debug(`<< AfterEach`);
34
+ await mongoFixtures.clear();
35
+ },
36
+ after: async () => {
37
+ //debug(`<< After`);
38
+ await mongoFixtures.close();
39
+ }
40
+ }
41
+ });
42
+
43
+ async function initMongofixtures() {
44
+ mongoFixtures = await mongoFixturesFactory({
45
+ recurse: false,
46
+ rootPath: [__dirname, '..', 'test-fixtures', 'mongo', 'add-blob-size'],
47
+ gridFS: {bucketName: 'foobar'},
48
+ useObjectId: true
49
+ });
50
+ }
51
+
52
+ // eslint-disable-next-line max-statements, complexity
53
+ async function callback({
54
+ getFixture,
55
+ functionName,
56
+ params,
57
+ expectModificationTime = false,
58
+ preFillDb = false,
59
+ expectedToThrow = false,
60
+ expectedErrorMessage = '',
61
+ expectedErrorStatus = ''
62
+ // contentStream = false,
63
+ // expectedOpResult = undefined,
64
+ // updateStateBeforeTest = undefined,
65
+ // resultIndex = undefined,
66
+ // createBulkParams = undefined,
67
+ // expectedFileCount = undefined,
68
+ // expectUndefined = undefined
69
+ }) {
70
+
71
+ const mongoUri = await mongoFixtures.getUri();
72
+ const mongoOperator = await createMongoOperator(mongoUri, 'foobar', '');
73
+ const expectedResult = await getFixture('expectedResult.json');
74
+
75
+ await doPreFillDb(preFillDb);
76
+
77
+ async function doPreFillDb(preFillDb) {
78
+ if (preFillDb) {
79
+ await mongoFixtures.populate(getFixture('dbContents.json'));
80
+ return;
81
+ }
82
+ return;
83
+ }
84
+
85
+ if (functionName === 'addBlobSize') {
86
+ try {
87
+ debug(`addBlobSize`);
88
+ debug(JSON.stringify(params));
89
+ //{correlationId}
90
+ const opResult = await mongoOperator.addBlobSize(params);
91
+ debug(`addBlobSize result: ${JSON.stringify(opResult)}`);
92
+ await compareToFirstDbEntry({mongoFixtures, expectedResult, expectModificationTime, formatDates: true});
93
+ } catch (error) {
94
+ handleError({error, expectedToThrow, expectedErrorMessage, expectedErrorStatus});
95
+ return;
96
+ }
97
+ return;
98
+ }
99
+ throw new Error(`Unknown functionName: ${functionName}`);
100
+ }