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

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.
package/package.json CHANGED
@@ -14,7 +14,7 @@
14
14
  "url": "git@github.com:natlibfi/melinda-rest-api-commons.git"
15
15
  },
16
16
  "license": "MIT",
17
- "version": "4.2.4-alpha.11",
17
+ "version": "4.2.4-alpha.13",
18
18
  "main": "./dist/index.js",
19
19
  "engines": {
20
20
  "node": ">=18"
@@ -39,7 +39,7 @@
39
39
  "@natlibfi/marc-record": "^9.1.3",
40
40
  "@natlibfi/marc-record-serializers": "^10.1.5",
41
41
  "@natlibfi/marc-record-validate": "^8.0.12",
42
- "@natlibfi/marc-record-validators-melinda": "^11.5.3",
42
+ "@natlibfi/marc-record-validators-melinda": "^11.5.4",
43
43
  "@natlibfi/melinda-backend-commons": "^2.3.6",
44
44
  "@natlibfi/melinda-commons": "^13.0.19",
45
45
  "amqplib": "^0.10.5",
@@ -47,13 +47,13 @@
47
47
  "http-status": "^2.1.0",
48
48
  "moment": "^2.30.1",
49
49
  "mongo-sanitize": "^1.1.0",
50
- "mongodb": "^6.12.0"
50
+ "mongodb": "^6.13.0"
51
51
  },
52
52
  "devDependencies": {
53
53
  "@babel/cli": "^7.26.4",
54
- "@babel/core": "^7.26.7",
55
- "@babel/plugin-transform-runtime": "^7.25.9",
56
- "@babel/preset-env": "^7.26.7",
54
+ "@babel/core": "^7.26.8",
55
+ "@babel/plugin-transform-runtime": "^7.26.8",
56
+ "@babel/preset-env": "^7.26.8",
57
57
  "@babel/register": "^7.25.9",
58
58
  "@natlibfi/eslint-config-melinda-backend": "^3.0.5",
59
59
  "@natlibfi/fixugen": "^2.0.12",
@@ -2,10 +2,9 @@
2
2
  import {READERS} from '@natlibfi/fixura';
3
3
  import mongoFixturesFactory from '@natlibfi/fixura-mongo';
4
4
  import generateTests from '@natlibfi/fixugen';
5
- import createMongoOperator from '../src/mongo';
6
5
  import createDebugLogger from 'debug';
7
6
  //import {handleError, compareToFirstDbEntry, compareToDbEntry, formatQueueItem, streamToString} from './testUtils';
8
- import {handleError, compareToFirstDbEntry} from './testUtils';
7
+ import {getMongoOperator, handleError, compareToFirstDbEntry} from './testUtils';
9
8
 
10
9
 
11
10
  let mongoFixtures; // eslint-disable-line functional/no-let
@@ -59,17 +58,10 @@ async function callback({
59
58
  expectedToThrow = false,
60
59
  expectedErrorMessage = '',
61
60
  expectedErrorStatus = ''
62
- // contentStream = false,
63
- // expectedOpResult = undefined,
64
- // updateStateBeforeTest = undefined,
65
- // resultIndex = undefined,
66
- // createBulkParams = undefined,
67
- // expectedFileCount = undefined,
68
- // expectUndefined = undefined
61
+
69
62
  }) {
70
63
 
71
- const mongoUri = await mongoFixtures.getUri();
72
- const mongoOperator = await createMongoOperator(mongoUri, 'foobar', '');
64
+ const mongoOperator = await getMongoOperator(mongoFixtures);
73
65
  const expectedResult = await getFixture('expectedResult.json');
74
66
 
75
67
  await doPreFillDb(preFillDb);
@@ -2,10 +2,9 @@ import {expect} from 'chai';
2
2
  import {READERS} from '@natlibfi/fixura';
3
3
  import mongoFixturesFactory from '@natlibfi/fixura-mongo';
4
4
  import generateTests from '@natlibfi/fixugen';
5
- import createMongoOperator from '../src/mongo';
6
5
  import createDebugLogger from 'debug';
7
6
  //import {handleError, compareToFirstDbEntry, compareToDbEntry, formatQueueItem, streamToString} from './testUtils';
8
- import {handleError, compareToFirstDbEntry} from './testUtils';
7
+ import {getMongoOperator, handleError, compareToFirstDbEntry} from './testUtils';
9
8
 
10
9
 
11
10
  let mongoFixtures; // eslint-disable-line functional/no-let
@@ -58,17 +57,11 @@ async function callback({
58
57
  expectedToThrow = false,
59
58
  expectedErrorMessage = '',
60
59
  expectedErrorStatus = '',
61
- //contentStream = false,
62
60
  expectedOpResult = undefined,
63
61
  updateStateBeforeTest = undefined
64
- //resultIndex = undefined,
65
- //createBulkParams = undefined,
66
- //expectedFileCount = undefined,
67
- //expectUndefined = undefined
68
62
  }) {
69
63
 
70
- const mongoUri = await mongoFixtures.getUri();
71
- const mongoOperator = await createMongoOperator(mongoUri, 'foobar', '');
64
+ const mongoOperator = await getMongoOperator(mongoFixtures);
72
65
  const expectedResult = await getFixture('expectedResult.json');
73
66
 
74
67
  await doPreFillDb(preFillDb);
@@ -2,10 +2,9 @@ import {expect} from 'chai';
2
2
  import {READERS} from '@natlibfi/fixura';
3
3
  import mongoFixturesFactory from '@natlibfi/fixura-mongo';
4
4
  import generateTests from '@natlibfi/fixugen';
5
- import createMongoOperator from '../src/mongo';
6
5
  import createDebugLogger from 'debug';
7
6
  //import {handleError, compareToFirstDbEntry, compareToDbEntry, formatQueueItem, streamToString} from './testUtils';
8
- import {handleError, compareToFirstDbEntry} from './testUtils';
7
+ import {getMongoOperator, handleError, compareToFirstDbEntry} from './testUtils';
9
8
 
10
9
  let mongoFixtures; // eslint-disable-line functional/no-let
11
10
  const debug = createDebugLogger('@natlibfi/melinda-rest-api-commons/mongo:check-and-set-import-job-state-test');
@@ -58,20 +57,12 @@ async function callback({
58
57
  expectedToThrow = false,
59
58
  expectedErrorMessage = '',
60
59
  expectedErrorStatus = '',
61
- //contentStream = false,
62
60
  expectedOpResult = undefined,
63
61
  updateStateBeforeTest = undefined
64
- //resultIndex = undefined,
65
- //createBulkParams = undefined,
66
- //expectedFileCount = undefined,
67
- //expectUndefined = undefined
68
62
  }) {
69
63
 
70
- const mongoUri = await mongoFixtures.getUri();
71
- const mongoOperator = await createMongoOperator(mongoUri, 'foobar', '');
64
+ const mongoOperator = await getMongoOperator(mongoFixtures);
72
65
  const expectedResult = await getFixture('expectedResult.json');
73
- // DEVELOP: we could use sama function for most of tests?
74
- // debug(typeof mongoUri); // eslint-disable-line
75
66
 
76
67
  await doPreFillDb(preFillDb);
77
68
 
@@ -89,6 +80,7 @@ async function callback({
89
80
  debug(JSON.stringify(params));
90
81
  //{correlationId, operation, importJobState, errorMessage = '', errorStatus = ''}
91
82
  // timeout
83
+
92
84
  // eslint-disable-next-line functional/no-conditional-statements
93
85
  if (updateStateBeforeTest && params.correlationId) {
94
86
  debug(`setState to reset modificationTime`);
@@ -2,10 +2,9 @@ import {expect} from 'chai';
2
2
  import {READERS} from '@natlibfi/fixura';
3
3
  import mongoFixturesFactory from '@natlibfi/fixura-mongo';
4
4
  import generateTests from '@natlibfi/fixugen';
5
- import createMongoOperator from '../src/mongo';
6
5
  import createDebugLogger from 'debug';
7
6
  //import {handleError, compareToFirstDbEntry, compareToDbEntry, formatQueueItem, streamToString} from './testUtils';
8
- import {handleError, compareToFirstDbEntry} from './testUtils';
7
+ import {getMongoOperator, handleError, compareToFirstDbEntry} from './testUtils';
9
8
 
10
9
 
11
10
  let mongoFixtures; // eslint-disable-line functional/no-let
@@ -59,17 +58,11 @@ async function callback({
59
58
  expectedToThrow = false,
60
59
  expectedErrorMessage = '',
61
60
  expectedErrorStatus = '',
62
- //contentStream = false,
63
61
  expectedOpResult = undefined,
64
62
  updateStateBeforeTest = undefined
65
- //resultIndex = undefined,
66
- //createBulkParams = undefined,
67
- //expectedFileCount = undefined,
68
- //expectUndefined = undefined
69
63
  }) {
70
64
 
71
- const mongoUri = await mongoFixtures.getUri();
72
- const mongoOperator = await createMongoOperator(mongoUri, 'foobar', '');
65
+ const mongoOperator = await getMongoOperator(mongoFixtures);
73
66
  const expectedResult = await getFixture('expectedResult.json');
74
67
 
75
68
  await doPreFillDb(preFillDb);
@@ -1,10 +1,9 @@
1
1
  import {READERS} from '@natlibfi/fixura';
2
2
  import mongoFixturesFactory from '@natlibfi/fixura-mongo';
3
3
  import generateTests from '@natlibfi/fixugen';
4
- import createMongoOperator from '../src/mongo';
5
4
  import createDebugLogger from 'debug';
6
5
  //import {handleError, compareToFirstDbEntry, compareToDbEntry, formatQueueItem, streamToString} from './testUtils';
7
- import {handleError, compareToFirstDbEntry} from './testUtils';
6
+ import {getMongoOperator, handleError, compareToFirstDbEntry} from './testUtils';
8
7
 
9
8
  let mongoFixtures; // eslint-disable-line functional/no-let
10
9
  const debug = createDebugLogger('@natlibfi/melinda-rest-api-commons/mongo:test:create-bulk');
@@ -52,32 +51,26 @@ async function callback({
52
51
  getFixture,
53
52
  functionName,
54
53
  params,
55
- //expectModificationTime = false,
56
54
  preFillDb = false,
57
55
  expectedToThrow = false,
58
56
  expectedErrorMessage = '',
59
57
  expectedErrorStatus = '',
60
58
  contentStream = false,
61
- //expectedOpResult = undefined,
62
- //updateStateBeforeTest = undefined,
63
- //resultIndex = undefined,
64
- //createBulkParams = undefined,
65
59
  expectedFileCount = undefined
66
- //expectUndefined = undefined
67
60
  }) {
68
61
 
69
- const mongoUri = await mongoFixtures.getUri();
70
- const mongoOperator = await createMongoOperator(mongoUri, 'foobar', '');
62
+ const mongoOperator = await getMongoOperator(mongoFixtures);
71
63
  const expectedResult = await getFixture('expectedResult.json');
72
- // DEVELOP: we could use sama function for most of tests?
73
- // debug(typeof mongoUri); // eslint-disable-line
74
64
 
75
- if (preFillDb) { // eslint-disable-line functional/no-conditional-statements
76
- await mongoFixtures.populate(getFixture('dbContents.json'));
77
- }
78
-
79
- //return {createPrio, createBulk, checkAndSetState, checkAndSetImportJobState, query, queryById, remove, readContent, removeContent, getOne, getStream, setState, setImportJobState, pushIds, pushMessages, setOperation, setOperations, addBlobSize, setBlobSize};
65
+ await doPreFillDb(preFillDb);
80
66
 
67
+ async function doPreFillDb(preFillDb) {
68
+ if (preFillDb) {
69
+ await mongoFixtures.populate(getFixture('dbContents.json'));
70
+ return;
71
+ }
72
+ return;
73
+ }
81
74
 
82
75
  if (functionName === 'createBulk') {
83
76
  try {
@@ -2,9 +2,8 @@
2
2
  import {READERS} from '@natlibfi/fixura';
3
3
  import mongoFixturesFactory from '@natlibfi/fixura-mongo';
4
4
  import generateTests from '@natlibfi/fixugen';
5
- import createMongoOperator from '../src/mongo';
6
5
  import createDebugLogger from 'debug';
7
- import {handleError, compareToFirstDbEntry} from './testUtils';
6
+ import {getMongoOperator, handleError, compareToFirstDbEntry} from './testUtils';
8
7
  // import {handleError, compareToFirstDbEntry, compareToDbEntry, formatQueueItem, streamToString} from './testUtils';
9
8
 
10
9
  let mongoFixtures; // eslint-disable-line functional/no-let
@@ -48,36 +47,28 @@ async function initMongofixtures() {
48
47
  });
49
48
  }
50
49
 
51
- // eslint-disable-next-line max-statements, complexity
52
50
  async function callback({
53
51
  getFixture,
54
52
  functionName,
55
53
  params,
56
- //expectModificationTime = false,
57
54
  preFillDb = false,
58
55
  expectedToThrow = false,
59
56
  expectedErrorMessage = '',
60
57
  expectedErrorStatus = ''
61
- //contentStream = false,
62
- //expectedOpResult = undefined,
63
- //updateStateBeforeTest = undefined,
64
- //resultIndex = undefined,
65
- //createBulkParams = undefined,
66
- //expectedFileCount = undefined,
67
- //expectUndefined = undefined
68
58
  }) {
69
59
 
70
- const mongoUri = await mongoFixtures.getUri();
71
- const mongoOperator = await createMongoOperator(mongoUri, 'foobar', '');
60
+ const mongoOperator = await getMongoOperator(mongoFixtures);
72
61
  const expectedResult = await getFixture('expectedResult.json');
73
- // DEVELOP: we could use sama function for most of tests?
74
- // debug(typeof mongoUri); // eslint-disable-line
75
62
 
76
- if (preFillDb) { // eslint-disable-line functional/no-conditional-statements
77
- await mongoFixtures.populate(getFixture('dbContents.json'));
78
- }
63
+ await doPreFillDb(preFillDb);
79
64
 
80
- //return {createPrio, createBulk, checkAndSetState, checkAndSetImportJobState, query, queryById, remove, readContent, removeContent, getOne, getStream, setState, setImportJobState, pushIds, pushMessages, setOperation, setOperations, addBlobSize, setBlobSize};
65
+ async function doPreFillDb(preFillDb) {
66
+ if (preFillDb) {
67
+ await mongoFixtures.populate(getFixture('dbContents.json'));
68
+ return;
69
+ }
70
+ return;
71
+ }
81
72
 
82
73
  if (functionName === 'createPrio') {
83
74
  try {
@@ -2,10 +2,9 @@ import {expect} from 'chai';
2
2
  import {READERS} from '@natlibfi/fixura';
3
3
  import mongoFixturesFactory from '@natlibfi/fixura-mongo';
4
4
  import generateTests from '@natlibfi/fixugen';
5
- import createMongoOperator from '../src/mongo';
6
5
  import createDebugLogger from 'debug';
7
6
  //import {handleError, compareToFirstDbEntry, compareToDbEntry, formatQueueItem, streamToString} from './testUtils';
8
- import {handleError} from './testUtils';
7
+ import {getMongoOperator, handleError} from './testUtils';
9
8
 
10
9
 
11
10
  let mongoFixtures; // eslint-disable-line functional/no-let
@@ -49,27 +48,18 @@ async function initMongofixtures() {
49
48
  });
50
49
  }
51
50
 
52
- // eslint-disable-next-line max-statements, complexity
53
51
  async function callback({
54
52
  getFixture,
55
53
  functionName,
56
54
  params,
57
- //expectModificationTime = false,
58
55
  preFillDb = false,
59
56
  expectedToThrow = false,
60
57
  expectedErrorMessage = '',
61
58
  expectedErrorStatus = '',
62
- //contentStream = false,
63
59
  expectedOpResult = undefined
64
- //updateStateBeforeTest = undefined,
65
- //resultIndex = undefined,
66
- //createBulkParams = undefined,
67
- //expectedFileCount = undefined,
68
- //expectUndefined = undefined
69
60
  }) {
70
61
 
71
- const mongoUri = await mongoFixtures.getUri();
72
- const mongoOperator = await createMongoOperator(mongoUri, 'foobar', '');
62
+ const mongoOperator = await getMongoOperator(mongoFixtures);
73
63
  //const expectedResult = await getFixture('expectedResult.json');
74
64
 
75
65
  await doPreFillDb(preFillDb);
@@ -2,10 +2,9 @@ import {expect} from 'chai';
2
2
  import {READERS} from '@natlibfi/fixura';
3
3
  import mongoFixturesFactory from '@natlibfi/fixura-mongo';
4
4
  import generateTests from '@natlibfi/fixugen';
5
- import createMongoOperator from '../src/mongo';
6
5
  import createDebugLogger from 'debug';
7
6
  //import {handleError, compareToFirstDbEntry, compareToDbEntry, formatQueueItem, streamToString} from './testUtils';
8
- import {handleError, streamToString} from './testUtils';
7
+ import {getMongoOperator, handleError, streamToString} from './testUtils';
9
8
 
10
9
  let mongoFixtures; // eslint-disable-line functional/no-let
11
10
  const debug = createDebugLogger('@natlibfi/melinda-rest-api-commons/mongo:get-stream:test');
@@ -48,27 +47,20 @@ async function initMongofixtures() {
48
47
  });
49
48
  }
50
49
 
51
- // eslint-disable-next-line max-statements, complexity
50
+ // eslint-disable-next-line max-statements
52
51
  async function callback({
53
52
  getFixture,
54
53
  functionName,
55
54
  params,
56
- //expectModificationTime = false,
57
55
  preFillDb = false,
58
56
  expectedToThrow = false,
59
57
  expectedErrorMessage = '',
60
58
  expectedErrorStatus = '',
61
59
  contentStream = false,
62
- //expectedOpResult = undefined,
63
- //updateStateBeforeTest = undefined,
64
- //resultIndex = undefined,
65
60
  createBulkParams = undefined
66
- //expectedFileCount = undefined,
67
- //expectUndefined = undefined
68
61
  }) {
69
62
 
70
- const mongoUri = await mongoFixtures.getUri();
71
- const mongoOperator = await createMongoOperator(mongoUri, 'foobar', '');
63
+ const mongoOperator = await getMongoOperator(mongoFixtures);
72
64
  //const expectedResult = await getFixture('expectedResult.json');
73
65
 
74
66
  await doPreFillDb(preFillDb);
@@ -1,10 +1,9 @@
1
1
  import {READERS} from '@natlibfi/fixura';
2
2
  import mongoFixturesFactory from '@natlibfi/fixura-mongo';
3
3
  import generateTests from '@natlibfi/fixugen';
4
- import createMongoOperator from '../src/mongo';
5
4
  import createDebugLogger from 'debug';
6
5
  //import {handleError, compareToFirstDbEntry, compareToDbEntry, formatQueueItem, streamToString} from './testUtils';
7
- import {handleError, compareToFirstDbEntry} from './testUtils';
6
+ import {getMongoOperator, handleError, compareToFirstDbEntry} from './testUtils';
8
7
 
9
8
 
10
9
  let mongoFixtures; // eslint-disable-line functional/no-let
@@ -48,7 +47,6 @@ async function initMongofixtures() {
48
47
  });
49
48
  }
50
49
 
51
- // eslint-disable-next-line max-statements, complexity
52
50
  async function callback({
53
51
  getFixture,
54
52
  functionName,
@@ -58,17 +56,9 @@ async function callback({
58
56
  expectedToThrow = false,
59
57
  expectedErrorMessage = '',
60
58
  expectedErrorStatus = ''
61
- //contentStream = false,
62
- //expectedOpResult = undefined,
63
- //updateStateBeforeTest = undefined,
64
- //resultIndex = undefined,
65
- //createBulkParams = undefined,
66
- //expectedFileCount = undefined,
67
- //expectUndefined = undefined
68
59
  }) {
69
60
 
70
- const mongoUri = await mongoFixtures.getUri();
71
- const mongoOperator = await createMongoOperator(mongoUri, 'foobar', '');
61
+ const mongoOperator = await getMongoOperator(mongoFixtures);
72
62
  const expectedResult = await getFixture('expectedResult.json');
73
63
 
74
64
  await doPreFillDb(preFillDb);
@@ -2,10 +2,9 @@
2
2
  import {READERS} from '@natlibfi/fixura';
3
3
  import mongoFixturesFactory from '@natlibfi/fixura-mongo';
4
4
  import generateTests from '@natlibfi/fixugen';
5
- import createMongoOperator from '../src/mongo';
6
5
  import createDebugLogger from 'debug';
7
6
  //import {handleError, compareToFirstDbEntry, compareToDbEntry, formatQueueItem, streamToString} from './testUtils';
8
- import {handleError, compareToFirstDbEntry} from './testUtils';
7
+ import {getMongoOperator, handleError, compareToFirstDbEntry} from './testUtils';
9
8
 
10
9
  let mongoFixtures; // eslint-disable-line functional/no-let
11
10
  const debug = createDebugLogger('@natlibfi/melinda-rest-api-commons/mongo:push-messages:test');
@@ -48,7 +47,6 @@ async function initMongofixtures() {
48
47
  });
49
48
  }
50
49
 
51
- // eslint-disable-next-line max-statements, complexity
52
50
  async function callback({
53
51
  getFixture,
54
52
  functionName,
@@ -58,17 +56,9 @@ async function callback({
58
56
  expectedToThrow = false,
59
57
  expectedErrorMessage = '',
60
58
  expectedErrorStatus = ''
61
- //contentStream = false,
62
- // expectedOpResult = undefined,
63
- // updateStateBeforeTest = undefined,
64
- // resultIndex = undefined,
65
- // createBulkParams = undefined,
66
- // expectedFileCount = undefined,
67
- // expectUndefined = undefined
68
59
  }) {
69
60
 
70
- const mongoUri = await mongoFixtures.getUri();
71
- const mongoOperator = await createMongoOperator(mongoUri, 'foobar', '');
61
+ const mongoOperator = await getMongoOperator(mongoFixtures);
72
62
  const expectedResult = await getFixture('expectedResult.json');
73
63
 
74
64
  await doPreFillDb(preFillDb);
@@ -2,10 +2,9 @@ import {expect} from 'chai';
2
2
  import {READERS} from '@natlibfi/fixura';
3
3
  import mongoFixturesFactory from '@natlibfi/fixura-mongo';
4
4
  import generateTests from '@natlibfi/fixugen';
5
- import createMongoOperator from '../src/mongo';
6
5
  import createDebugLogger from 'debug';
7
6
  //import {handleError, compareToFirstDbEntry, compareToDbEntry, formatQueueItem, streamToString} from './testUtils';
8
- import {handleError, compareToDbEntry, formatQueueItem} from './testUtils';
7
+ import {getMongoOperator, handleError, compareToDbEntry, formatQueueItem} from './testUtils';
9
8
 
10
9
 
11
10
  let mongoFixtures; // eslint-disable-line functional/no-let
@@ -49,7 +48,7 @@ async function initMongofixtures() {
49
48
  });
50
49
  }
51
50
 
52
- // eslint-disable-next-line max-statements, complexity
51
+ // eslint-disable-next-line max-statements
53
52
  async function callback({
54
53
  getFixture,
55
54
  functionName,
@@ -59,17 +58,12 @@ async function callback({
59
58
  expectedToThrow = false,
60
59
  expectedErrorMessage = '',
61
60
  expectedErrorStatus = '',
62
- //contentStream = false,
63
61
  expectedOpResult = undefined,
64
62
  updateStateBeforeTest = undefined,
65
63
  resultIndex = undefined
66
- //createBulkParams = undefined,
67
- //expectedFileCount = undefined,
68
- //expectUndefined = undefined
69
64
  }) {
70
65
 
71
- const mongoUri = await mongoFixtures.getUri();
72
- const mongoOperator = await createMongoOperator(mongoUri, 'foobar', '');
66
+ const mongoOperator = await getMongoOperator(mongoFixtures);
73
67
  const expectedResult = await getFixture('expectedResult.json');
74
68
 
75
69
  await doPreFillDb(preFillDb);
@@ -2,10 +2,9 @@ import {expect} from 'chai';
2
2
  import {READERS} from '@natlibfi/fixura';
3
3
  import mongoFixturesFactory from '@natlibfi/fixura-mongo';
4
4
  import generateTests from '@natlibfi/fixugen';
5
- import createMongoOperator from '../src/mongo';
6
5
  import createDebugLogger from 'debug';
7
6
  //import {handleError, compareToFirstDbEntry, compareToDbEntry, formatQueueItem, streamToString} from './testUtils';
8
- import {handleError} from './testUtils';
7
+ import {getMongoOperator, handleError} from './testUtils';
9
8
 
10
9
  let mongoFixtures; // eslint-disable-line functional/no-let
11
10
  const debug = createDebugLogger('@natlibfi/melinda-rest-api-commons/mongo:test');
@@ -48,27 +47,18 @@ async function initMongofixtures() {
48
47
  });
49
48
  }
50
49
 
51
- // eslint-disable-next-line max-statements, complexity
52
50
  async function callback({
53
51
  getFixture,
54
52
  functionName,
55
53
  params,
56
- //expectModificationTime = false,
57
54
  preFillDb = false,
58
55
  expectedToThrow = false,
59
56
  expectedErrorMessage = '',
60
57
  expectedErrorStatus = '',
61
- //contentStream = false,
62
58
  expectedOpResult = undefined
63
- //updateStateBeforeTest = undefined,
64
- //resultIndex = undefined,
65
- //createBulkParams = undefined,
66
- //expectedFileCount = undefined,
67
- //expectUndefined = undefined
68
59
  }) {
69
60
 
70
- const mongoUri = await mongoFixtures.getUri();
71
- const mongoOperator = await createMongoOperator(mongoUri, 'foobar', '');
61
+ const mongoOperator = await getMongoOperator(mongoFixtures);
72
62
  //const expectedResult = await getFixture('expectedResult.json');
73
63
 
74
64
  await doPreFillDb(preFillDb);
@@ -2,10 +2,9 @@ import {expect} from 'chai';
2
2
  import {READERS} from '@natlibfi/fixura';
3
3
  import mongoFixturesFactory from '@natlibfi/fixura-mongo';
4
4
  import generateTests from '@natlibfi/fixugen';
5
- import createMongoOperator from '../src/mongo';
6
5
  import createDebugLogger from 'debug';
7
6
  //import {handleError, compareToFirstDbEntry, compareToDbEntry, formatQueueItem, streamToString} from './testUtils';
8
- import {handleError, streamToString} from './testUtils';
7
+ import {getMongoOperator, handleError, streamToString} from './testUtils';
9
8
 
10
9
 
11
10
  let mongoFixtures; // eslint-disable-line functional/no-let
@@ -49,27 +48,20 @@ async function initMongofixtures() {
49
48
  });
50
49
  }
51
50
 
52
- // eslint-disable-next-line max-statements, complexity
51
+ // eslint-disable-next-line max-statements
53
52
  async function callback({
54
53
  getFixture,
55
54
  functionName,
56
55
  params,
57
- //expectModificationTime = false,
58
56
  preFillDb = false,
59
57
  expectedToThrow = false,
60
58
  expectedErrorMessage = '',
61
59
  expectedErrorStatus = '',
62
60
  contentStream = false,
63
- //expectedOpResult = undefined,
64
- //updateStateBeforeTest = undefined,
65
- //resultIndex = undefined,
66
61
  createBulkParams = undefined
67
- //expectedFileCount = undefined,
68
- //expectUndefined = undefined
69
62
  }) {
70
63
 
71
- const mongoUri = await mongoFixtures.getUri();
72
- const mongoOperator = await createMongoOperator(mongoUri, 'foobar', '');
64
+ const mongoOperator = await getMongoOperator(mongoFixtures);
73
65
  //const expectedResult = await getFixture('expectedResult.json');
74
66
 
75
67
  await doPreFillDb(preFillDb);
@@ -2,10 +2,9 @@
2
2
  import {READERS} from '@natlibfi/fixura';
3
3
  import mongoFixturesFactory from '@natlibfi/fixura-mongo';
4
4
  import generateTests from '@natlibfi/fixugen';
5
- import createMongoOperator from '../src/mongo';
6
5
  import createDebugLogger from 'debug';
7
6
  //import {handleError, compareToFirstDbEntry, compareToDbEntry, formatQueueItem, streamToString} from './testUtils';
8
- import {handleError, compareToFirstDbEntry} from './testUtils';
7
+ import {getMongoOperator, handleError, compareToFirstDbEntry} from './testUtils';
9
8
 
10
9
 
11
10
  let mongoFixtures; // eslint-disable-line functional/no-let
@@ -49,7 +48,7 @@ async function initMongofixtures() {
49
48
  });
50
49
  }
51
50
 
52
- // eslint-disable-next-line max-statements, complexity
51
+ // eslint-disable-next-line max-statements
53
52
  async function callback({
54
53
  getFixture,
55
54
  functionName,
@@ -60,16 +59,12 @@ async function callback({
60
59
  expectedErrorMessage = '',
61
60
  expectedErrorStatus = '',
62
61
  contentStream = false,
63
- //expectedOpResult = undefined,
64
- //updateStateBeforeTest = undefined,
65
- //resultIndex = undefined,
66
62
  createBulkParams = undefined,
67
63
  expectedFileCount = undefined,
68
64
  expectUndefined = undefined
69
65
  }) {
70
66
 
71
- const mongoUri = await mongoFixtures.getUri();
72
- const mongoOperator = await createMongoOperator(mongoUri, 'foobar', '');
67
+ const mongoOperator = await getMongoOperator(mongoFixtures);
73
68
  const expectedResult = await getFixture('expectedResult.json');
74
69
 
75
70
  await doPreFillDb(preFillDb);
@@ -2,10 +2,9 @@
2
2
  import {READERS} from '@natlibfi/fixura';
3
3
  import mongoFixturesFactory from '@natlibfi/fixura-mongo';
4
4
  import generateTests from '@natlibfi/fixugen';
5
- import createMongoOperator from '../src/mongo';
6
5
  import createDebugLogger from 'debug';
7
6
  //import {handleError, compareToFirstDbEntry, compareToDbEntry, formatQueueItem, streamToString} from './testUtils';
8
- import {handleError, compareToFirstDbEntry} from './testUtils';
7
+ import {getMongoOperator, handleError, compareToFirstDbEntry} from './testUtils';
9
8
 
10
9
  let mongoFixtures; // eslint-disable-line functional/no-let
11
10
  const debug = createDebugLogger('@natlibfi/melinda-rest-api-commons/mongo:set-blob-size:test');
@@ -48,7 +47,6 @@ async function initMongofixtures() {
48
47
  });
49
48
  }
50
49
 
51
- // eslint-disable-next-line max-statements, complexity
52
50
  async function callback({
53
51
  getFixture,
54
52
  functionName,
@@ -58,17 +56,9 @@ async function callback({
58
56
  expectedToThrow = false,
59
57
  expectedErrorMessage = '',
60
58
  expectedErrorStatus = ''
61
- // contentStream = false,
62
- // expectedOpResult = undefined,
63
- // updateStateBeforeTest = undefined,
64
- // resultIndex = undefined,
65
- // createBulkParams = undefined,
66
- // expectedFileCount = undefined,
67
- // expectUndefined = undefined
68
59
  }) {
69
60
 
70
- const mongoUri = await mongoFixtures.getUri();
71
- const mongoOperator = await createMongoOperator(mongoUri, 'foobar', '');
61
+ const mongoOperator = await getMongoOperator(mongoFixtures);
72
62
  const expectedResult = await getFixture('expectedResult.json');
73
63
 
74
64
  await doPreFillDb(preFillDb);
@@ -2,10 +2,9 @@
2
2
  import {READERS} from '@natlibfi/fixura';
3
3
  import mongoFixturesFactory from '@natlibfi/fixura-mongo';
4
4
  import generateTests from '@natlibfi/fixugen';
5
- import createMongoOperator from '../src/mongo';
6
5
  import createDebugLogger from 'debug';
7
6
  //import {handleError, compareToFirstDbEntry, compareToDbEntry, formatQueueItem, streamToString} from './testUtils';
8
- import {handleError, compareToFirstDbEntry} from './testUtils';
7
+ import {getMongoOperator, handleError, compareToFirstDbEntry} from './testUtils';
9
8
 
10
9
 
11
10
  let mongoFixtures; // eslint-disable-line functional/no-let
@@ -49,7 +48,6 @@ async function initMongofixtures() {
49
48
  });
50
49
  }
51
50
 
52
- // eslint-disable-next-line max-statements, complexity
53
51
  async function callback({
54
52
  getFixture,
55
53
  functionName,
@@ -59,17 +57,9 @@ async function callback({
59
57
  expectedToThrow = false,
60
58
  expectedErrorMessage = '',
61
59
  expectedErrorStatus = ''
62
- // contentStream = false,
63
- // expectedOpResult = undefined,
64
- // updateStateBeforeTest = undefined,
65
- // resultIndex = undefined,
66
- // createBulkParams = undefined,
67
- // expectedFileCount = undefined,
68
- // expectUndefined = undefined
69
60
  }) {
70
61
 
71
- const mongoUri = await mongoFixtures.getUri();
72
- const mongoOperator = await createMongoOperator(mongoUri, 'foobar', '');
62
+ const mongoOperator = await getMongoOperator(mongoFixtures);
73
63
  const expectedResult = await getFixture('expectedResult.json');
74
64
 
75
65
  await doPreFillDb(preFillDb);
@@ -2,10 +2,9 @@
2
2
  import {READERS} from '@natlibfi/fixura';
3
3
  import mongoFixturesFactory from '@natlibfi/fixura-mongo';
4
4
  import generateTests from '@natlibfi/fixugen';
5
- import createMongoOperator from '../src/mongo';
6
5
  import createDebugLogger from 'debug';
7
6
  //import {handleError, compareToFirstDbEntry, compareToDbEntry, formatQueueItem, streamToString} from './testUtils';
8
- import {handleError, compareToFirstDbEntry} from './testUtils';
7
+ import {getMongoOperator, handleError, compareToFirstDbEntry} from './testUtils';
9
8
 
10
9
  let mongoFixtures; // eslint-disable-line functional/no-let
11
10
  const debug = createDebugLogger('@natlibfi/melinda-rest-api-commons/mongo:set-operation:test');
@@ -48,7 +47,6 @@ async function initMongofixtures() {
48
47
  });
49
48
  }
50
49
 
51
- // eslint-disable-next-line max-statements, complexity
52
50
  async function callback({
53
51
  getFixture,
54
52
  functionName,
@@ -58,17 +56,9 @@ async function callback({
58
56
  expectedToThrow = false,
59
57
  expectedErrorMessage = '',
60
58
  expectedErrorStatus = ''
61
- // contentStream = false,
62
- // expectedOpResult = undefined,
63
- // updateStateBeforeTest = undefined,
64
- // resultIndex = undefined,
65
- // createBulkParams = undefined,
66
- // expectedFileCount = undefined,
67
- // expectUndefined = undefined
68
59
  }) {
69
60
 
70
- const mongoUri = await mongoFixtures.getUri();
71
- const mongoOperator = await createMongoOperator(mongoUri, 'foobar', '');
61
+ const mongoOperator = await getMongoOperator(mongoFixtures);
72
62
  const expectedResult = await getFixture('expectedResult.json');
73
63
 
74
64
  await doPreFillDb(preFillDb);
@@ -2,10 +2,9 @@
2
2
  import {READERS} from '@natlibfi/fixura';
3
3
  import mongoFixturesFactory from '@natlibfi/fixura-mongo';
4
4
  import generateTests from '@natlibfi/fixugen';
5
- import createMongoOperator from '../src/mongo';
6
5
  import createDebugLogger from 'debug';
7
6
  //import {handleError, compareToFirstDbEntry, compareToDbEntry, formatQueueItem, streamToString} from './testUtils';
8
- import {handleError, compareToFirstDbEntry} from './testUtils';
7
+ import {getMongoOperator, handleError, compareToFirstDbEntry} from './testUtils';
9
8
 
10
9
  let mongoFixtures; // eslint-disable-line functional/no-let
11
10
  const debug = createDebugLogger('@natlibfi/melinda-rest-api-commons/mongo:set-operations:test');
@@ -48,7 +47,6 @@ async function initMongofixtures() {
48
47
  });
49
48
  }
50
49
 
51
- // eslint-disable-next-line max-statements, complexity
52
50
  async function callback({
53
51
  getFixture,
54
52
  functionName,
@@ -58,17 +56,9 @@ async function callback({
58
56
  expectedToThrow = false,
59
57
  expectedErrorMessage = '',
60
58
  expectedErrorStatus = ''
61
- // contentStream = false,
62
- // expectedOpResult = undefined,
63
- // updateStateBeforeTest = undefined,
64
- // resultIndex = undefined,
65
- // createBulkParams = undefined,
66
- // expectedFileCount = undefined,
67
- // expectUndefined = undefined
68
59
  }) {
69
60
 
70
- const mongoUri = await mongoFixtures.getUri();
71
- const mongoOperator = await createMongoOperator(mongoUri, 'foobar', '');
61
+ const mongoOperator = await getMongoOperator(mongoFixtures);
72
62
  const expectedResult = await getFixture('expectedResult.json');
73
63
 
74
64
  await doPreFillDb(preFillDb);
@@ -2,10 +2,9 @@
2
2
  import {READERS} from '@natlibfi/fixura';
3
3
  import mongoFixturesFactory from '@natlibfi/fixura-mongo';
4
4
  import generateTests from '@natlibfi/fixugen';
5
- import createMongoOperator from '../src/mongo';
6
5
  import createDebugLogger from 'debug';
7
6
  //import {handleError, compareToFirstDbEntry, compareToDbEntry, formatQueueItem, streamToString} from './testUtils';
8
- import {handleError, compareToFirstDbEntry} from './testUtils';
7
+ import {getMongoOperator, handleError, compareToFirstDbEntry} from './testUtils';
9
8
 
10
9
 
11
10
  let mongoFixtures; // eslint-disable-line functional/no-let
@@ -49,7 +48,6 @@ async function initMongofixtures() {
49
48
  });
50
49
  }
51
50
 
52
- // eslint-disable-next-line max-statements, complexity
53
51
  async function callback({
54
52
  getFixture,
55
53
  functionName,
@@ -59,17 +57,9 @@ async function callback({
59
57
  expectedToThrow = false,
60
58
  expectedErrorMessage = '',
61
59
  expectedErrorStatus = ''
62
- // contentStream = false,
63
- // expectedOpResult = undefined,
64
- // updateStateBeforeTest = undefined,
65
- // resultIndex = undefined,
66
- // createBulkParams = undefined,
67
- // expectedFileCount = undefined,
68
- // expectUndefined = undefined
69
60
  }) {
70
61
 
71
- const mongoUri = await mongoFixtures.getUri();
72
- const mongoOperator = await createMongoOperator(mongoUri, 'foobar', '');
62
+ const mongoOperator = await getMongoOperator(mongoFixtures);
73
63
  const expectedResult = await getFixture('expectedResult.json');
74
64
 
75
65
  await doPreFillDb(preFillDb);
@@ -1,9 +1,17 @@
1
1
 
2
2
  import {expect} from 'chai';
3
3
  import createDebugLogger from 'debug';
4
+ import createMongoOperator from '../src/mongo';
5
+
4
6
 
5
7
  const debug = createDebugLogger('@natlibfi/melinda-rest-api-commons/mongo:test');
6
8
 
9
+ export async function getMongoOperator(mongoFixtures) {
10
+ const mongoUri = await mongoFixtures.getUri();
11
+ const mongoOperator = await createMongoOperator(mongoUri, 'foobar', '');
12
+ return mongoOperator;
13
+ }
14
+
7
15
  export async function compareToFirstDbEntry({mongoFixtures, expectedResult, expectModificationTime = false, formatDates = true, expectedFileCount = undefined}) {
8
16
  const result = await compareToDbEntry({mongoFixtures, expectedResult, resultIndex: 0, expectModificationTime, formatDates, expectedFileCount});
9
17
  return result;