@natlibfi/melinda-rest-api-commons 4.2.5 → 5.0.0-alpha.2
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/.github/workflows/melinda-node-tests.yml +9 -6
- package/dist/amqp.js +60 -151
- package/dist/amqp.js.map +7 -1
- package/dist/constants.js +40 -51
- package/dist/constants.js.map +7 -1
- package/dist/helpers/conversion.js +39 -57
- package/dist/helpers/conversion.js.map +7 -1
- package/dist/helpers/fix-constants.js +40 -47
- package/dist/helpers/fix-constants.js.map +7 -1
- package/dist/helpers/fix-handle-tempurns.js +23 -73
- package/dist/helpers/fix-handle-tempurns.js.map +7 -1
- package/dist/helpers/fix-strip-f884s.js +44 -94
- package/dist/helpers/fix-strip-f884s.js.map +7 -1
- package/dist/helpers/fix-utils.js +7 -22
- package/dist/helpers/fix-utils.js.map +7 -1
- package/dist/helpers/fix.js +62 -122
- package/dist/helpers/fix.js.map +7 -1
- package/dist/helpers/validation.js +12 -30
- package/dist/helpers/validation.js.map +7 -1
- package/dist/index.js +10 -109
- package/dist/index.js.map +7 -1
- package/dist/mongo.js +173 -509
- package/dist/mongo.js.map +7 -1
- package/dist/mongoLog.js +92 -317
- package/dist/mongoLog.js.map +7 -1
- package/dist/utils.js +46 -155
- package/dist/utils.js.map +7 -1
- package/eslint.config.js +53 -0
- package/package.json +23 -96
- package/tests/{amqp.health.spec.js → amqp.healthtest.js} +2 -2
- package/tests/{amqp.tests.spec.js → amqp.tests.localtest.js} +46 -46
- package/tests/helpers/{conversion.spec.js → conversion.test.js} +38 -25
- package/tests/helpers/{fix.spec.js → fix.test.js} +6 -6
- package/tests/helpers/{validation.spec.js → validation.test.js} +12 -9
- package/tests/{mongo-add-blob-size.spec.js → mongo-add-blob-size.test.js} +6 -6
- package/tests/{mongo-check-and-check-state.spec.js → mongo-check-and-check-state.test.js} +7 -7
- package/tests/{mongo-check-and-set-import-job-state.spec.js → mongo-check-and-set-import-job-state.test.js} +7 -7
- package/tests/{mongo-check-timeout.spec.js → mongo-check-timeout.test.js} +7 -7
- package/tests/{mongo-create-bulk.spec.js → mongo-create-bulk.test.js} +5 -5
- package/tests/{mongo-create-prio.spec.js → mongo-create-prio.test.js} +6 -6
- package/tests/{mongo-get-one.spec.js → mongo-get-one.test.js} +7 -7
- package/tests/{mongo-get-stream.spec.js → mongo-get-stream.test.js} +7 -7
- package/tests/{mongo-push-ids.spec.js → mongo-push-ids.test.js} +5 -5
- package/tests/{mongo-push-messages.spec.js → mongo-push-messages.test.js} +6 -6
- package/tests/{mongo-query-by-id.spec.js → mongo-query-by-id.test.js} +7 -7
- package/tests/{mongo-query.spec.js → mongo-query.test.js} +7 -7
- package/tests/{mongo-read-content.spec.js → mongo-read-content.test.js} +8 -8
- package/tests/{mongo-remove.spec.js → mongo-remove.test.js} +6 -6
- package/tests/{mongo-set-blob-size.spec.js → mongo-set-blob-size.test.js} +6 -6
- package/tests/{mongo-set-import-job-state.spec.js → mongo-set-import-job-state.test.js} +6 -6
- package/tests/{mongo-set-operation.spec.js → mongo-set-operation.test.js} +6 -6
- package/tests/{mongo-set-operations.spec.js → mongo-set-operations.test.js} +6 -6
- package/tests/{mongo-set-state.spec.js → mongo-set-state.test.js} +7 -7
- package/tests/{mongoLog.spec.js → mongoLog.test.js} +10 -11
- package/tests/testUtils.js +9 -8
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {READERS} from '@natlibfi/fixura';
|
|
1
|
+
import assert from 'node:assert';
|
|
3
2
|
import createDebugLogger from 'debug';
|
|
3
|
+
import {promisify} from 'util';
|
|
4
|
+
import {READERS} from '@natlibfi/fixura';
|
|
4
5
|
import generateTests from '@natlibfi/fixugen';
|
|
5
|
-
import {amqpFactory} from '../src/index';
|
|
6
6
|
import {Error as ApiError} from '@natlibfi/melinda-commons';
|
|
7
|
-
import {
|
|
7
|
+
import {amqpFactory} from '../src/index.js';
|
|
8
8
|
|
|
9
9
|
const setTimeoutPromise = promisify(setTimeout);
|
|
10
10
|
const debug = createDebugLogger('@natlibfi/melinda-rest-api-commons:amqp:test');
|
|
@@ -23,14 +23,14 @@ let amqpOperator;
|
|
|
23
23
|
|
|
24
24
|
generateTests({
|
|
25
25
|
callback,
|
|
26
|
-
path: [
|
|
26
|
+
path: [import.meta.dirname, '..', 'test-fixtures', 'amqp'],
|
|
27
27
|
recurse: false,
|
|
28
28
|
useMetadataFile: true,
|
|
29
29
|
fixura: {
|
|
30
30
|
failWhenNotFound: true,
|
|
31
31
|
reader: READERS.JSON
|
|
32
32
|
},
|
|
33
|
-
|
|
33
|
+
hooks: {
|
|
34
34
|
before: async () => {
|
|
35
35
|
debug(`Connecting to ${amqpUrl}, with healthCheck running`);
|
|
36
36
|
amqpOperator = await amqpFactory(amqpUrl, true);
|
|
@@ -76,13 +76,13 @@ async function callback({
|
|
|
76
76
|
|
|
77
77
|
const messageCount = await amqpOperator.checkQueue({queue, style: 'messages'});
|
|
78
78
|
debug(`MessageCount: ${messageCount}`);
|
|
79
|
-
|
|
79
|
+
assert.equal(messageCount, expectedMessageCount);
|
|
80
80
|
|
|
81
81
|
if (checkNextMessage) {
|
|
82
82
|
const {headers, records} = await queueCheckNextMessage();
|
|
83
83
|
const nextMessage = {headers, records};
|
|
84
84
|
const expectedNextMessage = getFixture('expectedMessage.json');
|
|
85
|
-
|
|
85
|
+
assert.equal(nextMessage, expectedNextMessage);
|
|
86
86
|
return;
|
|
87
87
|
}
|
|
88
88
|
|
|
@@ -90,25 +90,25 @@ async function callback({
|
|
|
90
90
|
if (!expectToFail) {
|
|
91
91
|
throw error;
|
|
92
92
|
}
|
|
93
|
-
|
|
93
|
+
assert.equal(expectToFail, true, 'This is expected to fail');
|
|
94
94
|
testErrors(error);
|
|
95
95
|
}
|
|
96
96
|
|
|
97
97
|
function testErrors(error) {
|
|
98
|
-
|
|
98
|
+
const isApiError = error instanceof ApiError;
|
|
99
99
|
if (expectApiError) {
|
|
100
|
-
|
|
100
|
+
assert.equal(isApiError, true);
|
|
101
101
|
debug(`We expected and got an ApiError`);
|
|
102
|
-
|
|
102
|
+
assert.equal(error.status, expectedErrorStatus);
|
|
103
103
|
|
|
104
104
|
if (expectedErrorMessage) {
|
|
105
|
-
|
|
105
|
+
assert.equal(error.payload, expectedErrorMessage);
|
|
106
106
|
return;
|
|
107
107
|
}
|
|
108
108
|
|
|
109
109
|
return;
|
|
110
110
|
}
|
|
111
|
-
|
|
111
|
+
assert.equal(isApiError, false);
|
|
112
112
|
debug(`We expected and got an non-ApiError`);
|
|
113
113
|
debug(`Error is a ${error.constructor.name}`);
|
|
114
114
|
}
|
|
@@ -141,11 +141,11 @@ async function callback({
|
|
|
141
141
|
return;
|
|
142
142
|
}
|
|
143
143
|
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
144
|
+
assert.equal(Object.hasOwn(result, 'headers'), true);
|
|
145
|
+
assert.equal(Object.hasOwn(result, 'records'), true);
|
|
146
|
+
assert.equal(Object.hasOwn(result, 'messages'), true);
|
|
147
|
+
assert.equal(result.records.length, 1);
|
|
148
|
+
assert.equal(result.messages.length, 1);
|
|
149
149
|
|
|
150
150
|
return;
|
|
151
151
|
}
|
|
@@ -159,15 +159,15 @@ async function callback({
|
|
|
159
159
|
return;
|
|
160
160
|
}
|
|
161
161
|
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
162
|
+
assert.equal(Object.hasOwn(result, 'deliveryTag'), true);
|
|
163
|
+
assert.equal(Object.hasOwn(result, 'exchange'), true);
|
|
164
|
+
assert.equal(Object.hasOwn(result, 'messageCount'), true);
|
|
165
|
+
assert.equal(Object.hasOwn(result, 'redelivered'), true);
|
|
166
|
+
assert.equal(Object.hasOwn(result, 'routingKey'), true);
|
|
167
|
+
assert.equal(typeof fields.deliveryTag, 'number');
|
|
168
|
+
assert.equal(typeof fields.messageCount, 'number');
|
|
169
|
+
assert.equal(typeof fields.redelivered, 'boolean');
|
|
170
|
+
assert.equal(typeof fields.routingKey, 'string');
|
|
171
171
|
|
|
172
172
|
return;
|
|
173
173
|
}
|
|
@@ -180,13 +180,13 @@ async function callback({
|
|
|
180
180
|
return;
|
|
181
181
|
}
|
|
182
182
|
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
183
|
+
assert.equal(Object.hasOwn(result, 'headers'), true);
|
|
184
|
+
assert.equal(Object.hasOwn(result, 'records'), true);
|
|
185
|
+
assert.equal(Object.hasOwn(result, 'messages'), true);
|
|
186
|
+
assert.equal(result.records.length, 3);
|
|
187
|
+
assert.equal(result.messages.length, 3);
|
|
188
188
|
const expectedResult = getFixture('expectedResult.json');
|
|
189
|
-
|
|
189
|
+
assert.deepStrictEqual(result.records, expectedResult);
|
|
190
190
|
|
|
191
191
|
return;
|
|
192
192
|
}
|
|
@@ -199,22 +199,22 @@ async function callback({
|
|
|
199
199
|
return;
|
|
200
200
|
}
|
|
201
201
|
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
202
|
+
assert.equal(Object.hasOwn(result, 'headers'), true);
|
|
203
|
+
assert.equal(Object.hasOwn(result, 'messages'), true);
|
|
204
|
+
assert.equal(result.messages.length, 3);
|
|
205
205
|
|
|
206
206
|
const [{fields}] = result.messages;
|
|
207
207
|
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
208
|
+
assert.equal(Object.hasOwn(result, 'deliveryTag'), true);
|
|
209
|
+
assert.equal(Object.hasOwn(result, 'exchange'), true);
|
|
210
|
+
assert.equal(Object.hasOwn(result, 'messageCount'), true);
|
|
211
|
+
assert.equal(Object.hasOwn(result, 'redelivered'), true);
|
|
212
|
+
assert.equal(Object.hasOwn(result, 'routingKey'), true);
|
|
213
213
|
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
214
|
+
assert.equal(typeof fields.deliveryTag, 'number');
|
|
215
|
+
assert.equal(typeof fields.messageCount, 'number');
|
|
216
|
+
assert.equal(typeof fields.redelivered, 'boolean');
|
|
217
|
+
assert.equal(typeof fields.routingKey, 'string');
|
|
218
218
|
|
|
219
219
|
return;
|
|
220
220
|
}
|
|
@@ -1,20 +1,23 @@
|
|
|
1
1
|
|
|
2
2
|
|
|
3
|
-
import
|
|
3
|
+
import assert from 'node:assert';
|
|
4
|
+
import {describe, it} from 'node:test';
|
|
4
5
|
import fixtureFactory from '@natlibfi/fixura';
|
|
5
6
|
import {MarcRecord} from '@natlibfi/marc-record';
|
|
6
7
|
import {Error as ConversionError} from '@natlibfi/melinda-commons';
|
|
7
|
-
import createConversionService from '../../src/helpers/conversion';
|
|
8
|
-
import {CONVERSION_FORMATS} from '../../src/constants';
|
|
8
|
+
import createConversionService from '../../src/helpers/conversion.js';
|
|
9
|
+
import {CONVERSION_FORMATS} from '../../src/constants.js';
|
|
9
10
|
|
|
10
11
|
describe('services/conversion', () => {
|
|
11
|
-
const {getFixture} = fixtureFactory({
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
12
|
+
const {getFixture} = fixtureFactory({
|
|
13
|
+
root: [
|
|
14
|
+
import.meta.dirname,
|
|
15
|
+
'..',
|
|
16
|
+
'..',
|
|
17
|
+
'test-fixtures',
|
|
18
|
+
'conversion'
|
|
19
|
+
]
|
|
20
|
+
});
|
|
18
21
|
const conversionService = createConversionService();
|
|
19
22
|
|
|
20
23
|
const marcRecord = new MarcRecord(JSON.parse(getFixture({components: ['json1']})), {subfieldValues: false});
|
|
@@ -27,69 +30,79 @@ describe('services/conversion', () => {
|
|
|
27
30
|
describe('factory', () => {
|
|
28
31
|
it('Should create the expected object', () => {
|
|
29
32
|
const service = createConversionService();
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
+
assert.equal(typeof service, 'object');
|
|
34
|
+
assert.equal(Object.hasOwn(service, 'serialize'), true);
|
|
35
|
+
assert.equal(Object.hasOwn(service, 'unserialize'), true);
|
|
33
36
|
});
|
|
34
37
|
});
|
|
35
38
|
|
|
36
39
|
describe('#serialize', () => {
|
|
37
40
|
it('Should throw because of unsupported format', () => {
|
|
38
|
-
|
|
41
|
+
try {
|
|
42
|
+
conversionService.serialize();
|
|
43
|
+
} catch (error) {
|
|
44
|
+
assert(error instanceof ConversionError);
|
|
45
|
+
}
|
|
39
46
|
});
|
|
40
47
|
|
|
41
48
|
it('Should serialize to MARCXML', () => {
|
|
42
49
|
const data = conversionService.serialize(marcRecord, CONVERSION_FORMATS.MARCXML);
|
|
43
|
-
|
|
50
|
+
assert.equal(data, marcXml);
|
|
44
51
|
});
|
|
45
52
|
|
|
46
53
|
it('Should serialize to ISO2709', () => {
|
|
47
54
|
const data = conversionService.serialize(marcRecord, CONVERSION_FORMATS.ISO2709);
|
|
48
|
-
|
|
55
|
+
assert.equal(data, iso2709);
|
|
49
56
|
});
|
|
50
57
|
|
|
51
58
|
it('Should serialize to JSON', () => {
|
|
52
59
|
const data = conversionService.serialize(marcRecord, CONVERSION_FORMATS.JSON);
|
|
53
|
-
|
|
60
|
+
assert.equal(data, json);
|
|
54
61
|
});
|
|
55
62
|
|
|
56
63
|
it('Should serialize to aleph sequential', () => {
|
|
57
64
|
const data = conversionService.serialize(marcRecord, CONVERSION_FORMATS.ALEPHSEQ);
|
|
58
|
-
|
|
65
|
+
assert.equal(data, alephSeq);
|
|
59
66
|
});
|
|
60
67
|
|
|
61
68
|
});
|
|
62
69
|
|
|
63
70
|
describe('#unserialize', () => {
|
|
64
71
|
it('Should throw because of unsupported format', () => {
|
|
65
|
-
|
|
72
|
+
try {
|
|
73
|
+
conversionService.unserialize();
|
|
74
|
+
} catch (error) {
|
|
75
|
+
assert(error instanceof ConversionError);
|
|
76
|
+
}
|
|
66
77
|
});
|
|
67
78
|
|
|
68
79
|
it('Should unserialize from MARCXML', async () => {
|
|
69
80
|
const record = await conversionService.unserialize(marcXml, CONVERSION_FORMATS.MARCXML);
|
|
70
|
-
|
|
81
|
+
assert.equal(record.equalsTo(marcRecord), true);
|
|
71
82
|
});
|
|
72
83
|
|
|
73
84
|
it('Should unserialize from ISO2709', () => {
|
|
74
85
|
const record = conversionService.unserialize(iso2709, CONVERSION_FORMATS.ISO2709);
|
|
75
|
-
|
|
86
|
+
assert.equal(record.equalsTo(marcRecord), true);
|
|
76
87
|
});
|
|
77
88
|
|
|
78
89
|
it('Should unserialize from JSON', () => {
|
|
79
90
|
const record = conversionService.unserialize(json, CONVERSION_FORMATS.JSON);
|
|
80
|
-
|
|
91
|
+
assert.equal(record.equalsTo(marcRecord), true);
|
|
81
92
|
});
|
|
82
93
|
|
|
83
94
|
it('Should unserialize from Aleph sequential', () => {
|
|
84
95
|
const record = conversionService.unserialize(alephSeq, CONVERSION_FORMATS.ALEPHSEQ);
|
|
85
|
-
|
|
96
|
+
assert.equal(record.equalsTo(marcRecord), true);
|
|
86
97
|
});
|
|
87
98
|
|
|
88
99
|
|
|
89
100
|
it('Should throw because the record could not be unserialized', () => {
|
|
90
|
-
|
|
101
|
+
try {
|
|
91
102
|
conversionService.unserialize('', CONVERSION_FORMATS.JSON);
|
|
92
|
-
}
|
|
103
|
+
} catch (error) {
|
|
104
|
+
assert(error instanceof ConversionError);
|
|
105
|
+
}
|
|
93
106
|
});
|
|
94
107
|
});
|
|
95
108
|
});
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import
|
|
1
|
+
import assert from 'node:assert';
|
|
2
|
+
import createDebugLogger from 'debug';
|
|
2
3
|
import {MarcRecord} from '@natlibfi/marc-record';
|
|
3
4
|
import {READERS} from '@natlibfi/fixura';
|
|
4
5
|
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';
|
|
6
|
+
import {fixRecord} from '../../src/helpers/fix.js';
|
|
7
|
+
import * as fixSettings from '../../src/helpers/fix-constants.js';
|
|
8
8
|
// import inspect from 'util';
|
|
9
9
|
|
|
10
10
|
const debug = createDebugLogger('@natlibfi/melinda-rest-api-commons:fix:test');
|
|
@@ -12,7 +12,7 @@ const debugData = debug.extend('data');
|
|
|
12
12
|
|
|
13
13
|
generateTests({
|
|
14
14
|
callback,
|
|
15
|
-
path: [
|
|
15
|
+
path: [import.meta.dirname, '..', '..', 'test-fixtures', 'fix'],
|
|
16
16
|
recurse: true,
|
|
17
17
|
useMetadataFile: true,
|
|
18
18
|
fixura: {
|
|
@@ -36,6 +36,6 @@ function callback({getFixture, settings = undefined}) {
|
|
|
36
36
|
const resultRecord = fixRecord(record, runSettings);
|
|
37
37
|
debugData(`Result: ${JSON.stringify(resultRecord)}`);
|
|
38
38
|
debugData(`Expected: ${JSON.stringify(expectedRecord)}`);
|
|
39
|
-
|
|
39
|
+
assert.deepStrictEqual(resultRecord, expectedRecord);
|
|
40
40
|
|
|
41
41
|
}
|
|
@@ -1,11 +1,12 @@
|
|
|
1
|
-
import
|
|
1
|
+
import assert from 'node:assert';
|
|
2
|
+
import {describe, it} from 'node:test';
|
|
2
3
|
import fixtureFactory, {READERS} from '@natlibfi/fixura';
|
|
3
4
|
import {MarcRecord} from '@natlibfi/marc-record';
|
|
4
|
-
import createValidator from '../../src/helpers/validation';
|
|
5
|
+
import createValidator from '../../src/helpers/validation.js';
|
|
5
6
|
|
|
6
7
|
describe('services/validate', () => {
|
|
7
8
|
const FIXTURES_PATH = [
|
|
8
|
-
|
|
9
|
+
import.meta.dirname,
|
|
9
10
|
'..',
|
|
10
11
|
'..',
|
|
11
12
|
'test-fixtures',
|
|
@@ -23,14 +24,15 @@ describe('services/validate', () => {
|
|
|
23
24
|
]
|
|
24
25
|
}));
|
|
25
26
|
const result = await validator(record.toObject());
|
|
26
|
-
const
|
|
27
|
+
const {record: expectedRecord, ...rest} = getFixture({
|
|
27
28
|
components: [
|
|
28
29
|
'out',
|
|
29
30
|
'f003-fi-melinda.json'
|
|
30
31
|
]
|
|
31
32
|
});
|
|
32
|
-
|
|
33
|
-
|
|
33
|
+
const {_validationOptions, ...expectedRecordData} = expectedRecord;
|
|
34
|
+
assert.deepStrictEqual(result, {...rest, record: new MarcRecord(expectedRecordData, _validationOptions)});
|
|
35
|
+
assert.equal(result.failed, false);
|
|
34
36
|
});
|
|
35
37
|
});
|
|
36
38
|
|
|
@@ -44,14 +46,15 @@ describe('services/validate', () => {
|
|
|
44
46
|
]
|
|
45
47
|
}));
|
|
46
48
|
const result = await validator(record.toObject());
|
|
47
|
-
const
|
|
49
|
+
const {record: expectedRecord, ...rest} = getFixture({
|
|
48
50
|
components: [
|
|
49
51
|
'out',
|
|
50
52
|
'f003-not-fi-melinda.json'
|
|
51
53
|
]
|
|
52
54
|
});
|
|
53
|
-
|
|
54
|
-
|
|
55
|
+
const {_validationOptions, ...expectedRecordData} = expectedRecord;
|
|
56
|
+
assert.deepStrictEqual(result, {...rest, record: new MarcRecord(expectedRecordData, _validationOptions)});
|
|
57
|
+
assert.equal(result.failed, true);
|
|
55
58
|
});
|
|
56
59
|
});
|
|
57
60
|
});
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
//import
|
|
1
|
+
//import assert from 'node:assert';
|
|
2
2
|
import {READERS} from '@natlibfi/fixura';
|
|
3
3
|
import mongoFixturesFactory from '@natlibfi/fixura-mongo';
|
|
4
4
|
import generateTests from '@natlibfi/fixugen';
|
|
5
5
|
import createDebugLogger from 'debug';
|
|
6
|
-
//import {handleError, compareToFirstDbEntry, compareToDbEntry, formatQueueItem, streamToString} from './testUtils';
|
|
7
|
-
import {getMongoOperator, handleError, compareToFirstDbEntry} from './testUtils';
|
|
6
|
+
//import {handleError, compareToFirstDbEntry, compareToDbEntry, formatQueueItem, streamToString} from './testUtils.js';
|
|
7
|
+
import {getMongoOperator, handleError, compareToFirstDbEntry} from './testUtils.js';
|
|
8
8
|
|
|
9
9
|
|
|
10
10
|
let mongoFixtures; // eslint-disable-line functional/no-let
|
|
@@ -12,14 +12,14 @@ const debug = createDebugLogger('@natlibfi/melinda-rest-api-commons/mongo:add-bl
|
|
|
12
12
|
|
|
13
13
|
generateTests({
|
|
14
14
|
callback,
|
|
15
|
-
path: [
|
|
15
|
+
path: [import.meta.dirname, '..', 'test-fixtures', 'mongo', 'add-blob-size'],
|
|
16
16
|
recurse: false,
|
|
17
17
|
useMetadataFile: true,
|
|
18
18
|
fixura: {
|
|
19
19
|
failWhenNotFound: true,
|
|
20
20
|
reader: READERS.JSON
|
|
21
21
|
},
|
|
22
|
-
|
|
22
|
+
hooks: {
|
|
23
23
|
before: async () => {
|
|
24
24
|
//debug(`<< Before`);
|
|
25
25
|
await initMongofixtures();
|
|
@@ -42,7 +42,7 @@ generateTests({
|
|
|
42
42
|
async function initMongofixtures() {
|
|
43
43
|
mongoFixtures = await mongoFixturesFactory({
|
|
44
44
|
recurse: false,
|
|
45
|
-
rootPath: [
|
|
45
|
+
rootPath: [import.meta.dirname, '..', 'test-fixtures', 'mongo', 'add-blob-size'],
|
|
46
46
|
gridFS: {bucketName: 'foobar'},
|
|
47
47
|
useObjectId: true
|
|
48
48
|
});
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import
|
|
1
|
+
import assert from 'node:assert';
|
|
2
2
|
import {READERS} from '@natlibfi/fixura';
|
|
3
3
|
import mongoFixturesFactory from '@natlibfi/fixura-mongo';
|
|
4
4
|
import generateTests from '@natlibfi/fixugen';
|
|
5
5
|
import createDebugLogger from 'debug';
|
|
6
|
-
//import {handleError, compareToFirstDbEntry, compareToDbEntry, formatQueueItem, streamToString} from './testUtils';
|
|
7
|
-
import {getMongoOperator, handleError, compareToFirstDbEntry} from './testUtils';
|
|
6
|
+
//import {handleError, compareToFirstDbEntry, compareToDbEntry, formatQueueItem, streamToString} from './testUtils.js';
|
|
7
|
+
import {getMongoOperator, handleError, compareToFirstDbEntry} from './testUtils.js';
|
|
8
8
|
|
|
9
9
|
|
|
10
10
|
let mongoFixtures; // eslint-disable-line functional/no-let
|
|
@@ -12,14 +12,14 @@ const debug = createDebugLogger('@natlibfi/melinda-rest-api-commons/mongo:test')
|
|
|
12
12
|
|
|
13
13
|
generateTests({
|
|
14
14
|
callback,
|
|
15
|
-
path: [
|
|
15
|
+
path: [import.meta.dirname, '..', 'test-fixtures', 'mongo', 'check-and-set-state'],
|
|
16
16
|
recurse: false,
|
|
17
17
|
useMetadataFile: true,
|
|
18
18
|
fixura: {
|
|
19
19
|
failWhenNotFound: true,
|
|
20
20
|
reader: READERS.JSON
|
|
21
21
|
},
|
|
22
|
-
|
|
22
|
+
hooks: {
|
|
23
23
|
before: async () => {
|
|
24
24
|
//debug(`<< Before`);
|
|
25
25
|
await initMongofixtures();
|
|
@@ -42,7 +42,7 @@ generateTests({
|
|
|
42
42
|
async function initMongofixtures() {
|
|
43
43
|
mongoFixtures = await mongoFixturesFactory({
|
|
44
44
|
recurse: false,
|
|
45
|
-
rootPath: [
|
|
45
|
+
rootPath: [import.meta.dirname, '..', 'test-fixtures', 'mongo', 'check-and-set-state'],
|
|
46
46
|
gridFS: {bucketName: 'foobar'},
|
|
47
47
|
useObjectId: true
|
|
48
48
|
});
|
|
@@ -91,7 +91,7 @@ async function callback({
|
|
|
91
91
|
|
|
92
92
|
// eslint-disable-next-line functional/no-conditional-statements
|
|
93
93
|
if (expectedOpResult !== undefined) {
|
|
94
|
-
|
|
94
|
+
assert.deepStrictEqual(opResult, expectedOpResult);
|
|
95
95
|
}
|
|
96
96
|
await compareToFirstDbEntry({mongoFixtures, expectedResult, expectModificationTime, formatDates: true});
|
|
97
97
|
|
|
@@ -1,24 +1,24 @@
|
|
|
1
|
-
import
|
|
1
|
+
import assert from 'node:assert';
|
|
2
2
|
import {READERS} from '@natlibfi/fixura';
|
|
3
3
|
import mongoFixturesFactory from '@natlibfi/fixura-mongo';
|
|
4
4
|
import generateTests from '@natlibfi/fixugen';
|
|
5
5
|
import createDebugLogger from 'debug';
|
|
6
|
-
//import {handleError, compareToFirstDbEntry, compareToDbEntry, formatQueueItem, streamToString} from './testUtils';
|
|
7
|
-
import {getMongoOperator, handleError, compareToFirstDbEntry} from './testUtils';
|
|
6
|
+
//import {handleError, compareToFirstDbEntry, compareToDbEntry, formatQueueItem, streamToString} from './testUtils.js';
|
|
7
|
+
import {getMongoOperator, handleError, compareToFirstDbEntry} from './testUtils.js';
|
|
8
8
|
|
|
9
9
|
let mongoFixtures; // eslint-disable-line functional/no-let
|
|
10
10
|
const debug = createDebugLogger('@natlibfi/melinda-rest-api-commons/mongo:check-and-set-import-job-state-test');
|
|
11
11
|
|
|
12
12
|
generateTests({
|
|
13
13
|
callback,
|
|
14
|
-
path: [
|
|
14
|
+
path: [import.meta.dirname, '..', 'test-fixtures', 'mongo', 'check-and-set-import-job-state'],
|
|
15
15
|
recurse: false,
|
|
16
16
|
useMetadataFile: true,
|
|
17
17
|
fixura: {
|
|
18
18
|
failWhenNotFound: true,
|
|
19
19
|
reader: READERS.JSON
|
|
20
20
|
},
|
|
21
|
-
|
|
21
|
+
hooks: {
|
|
22
22
|
before: async () => {
|
|
23
23
|
//debug(`<< Before`);
|
|
24
24
|
await initMongofixtures();
|
|
@@ -41,7 +41,7 @@ generateTests({
|
|
|
41
41
|
async function initMongofixtures() {
|
|
42
42
|
mongoFixtures = await mongoFixturesFactory({
|
|
43
43
|
recurse: false,
|
|
44
|
-
rootPath: [
|
|
44
|
+
rootPath: [import.meta.dirname, '..', 'test-fixtures', 'mongo', 'check-and-set-import-job-state'],
|
|
45
45
|
gridFS: {bucketName: 'foobar'},
|
|
46
46
|
useObjectId: true
|
|
47
47
|
});
|
|
@@ -91,7 +91,7 @@ async function callback({
|
|
|
91
91
|
|
|
92
92
|
// eslint-disable-next-line functional/no-conditional-statements
|
|
93
93
|
if (expectedOpResult !== undefined) {
|
|
94
|
-
|
|
94
|
+
assert.deepStrictEqual(opResult, expectedOpResult);
|
|
95
95
|
}
|
|
96
96
|
await compareToFirstDbEntry({mongoFixtures, expectedResult, expectModificationTime, formatDates: true});
|
|
97
97
|
} catch (error) {
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import
|
|
1
|
+
import assert from 'node:assert';
|
|
2
2
|
import {READERS} from '@natlibfi/fixura';
|
|
3
3
|
import mongoFixturesFactory from '@natlibfi/fixura-mongo';
|
|
4
4
|
import generateTests from '@natlibfi/fixugen';
|
|
5
5
|
import createDebugLogger from 'debug';
|
|
6
|
-
//import {handleError, compareToFirstDbEntry, compareToDbEntry, formatQueueItem, streamToString} from './testUtils';
|
|
7
|
-
import {getMongoOperator, handleError, compareToFirstDbEntry} from './testUtils';
|
|
6
|
+
//import {handleError, compareToFirstDbEntry, compareToDbEntry, formatQueueItem, streamToString} from './testUtils.js';
|
|
7
|
+
import {getMongoOperator, handleError, compareToFirstDbEntry} from './testUtils.js';
|
|
8
8
|
|
|
9
9
|
|
|
10
10
|
let mongoFixtures; // eslint-disable-line functional/no-let
|
|
@@ -12,14 +12,14 @@ const debug = createDebugLogger('@natlibfi/melinda-rest-api-commons/mongo:check-
|
|
|
12
12
|
|
|
13
13
|
generateTests({
|
|
14
14
|
callback,
|
|
15
|
-
path: [
|
|
15
|
+
path: [import.meta.dirname, '..', 'test-fixtures', 'mongo', 'check-timeout'],
|
|
16
16
|
recurse: false,
|
|
17
17
|
useMetadataFile: true,
|
|
18
18
|
fixura: {
|
|
19
19
|
failWhenNotFound: true,
|
|
20
20
|
reader: READERS.JSON
|
|
21
21
|
},
|
|
22
|
-
|
|
22
|
+
hooks: {
|
|
23
23
|
before: async () => {
|
|
24
24
|
//debug(`<< Before`);
|
|
25
25
|
await initMongofixtures();
|
|
@@ -42,7 +42,7 @@ generateTests({
|
|
|
42
42
|
async function initMongofixtures() {
|
|
43
43
|
mongoFixtures = await mongoFixturesFactory({
|
|
44
44
|
recurse: false,
|
|
45
|
-
rootPath: [
|
|
45
|
+
rootPath: [import.meta.dirname, '..', 'test-fixtures', 'mongo', 'check-timeout'],
|
|
46
46
|
gridFS: {bucketName: 'foobar'},
|
|
47
47
|
useObjectId: true
|
|
48
48
|
});
|
|
@@ -91,7 +91,7 @@ async function callback({
|
|
|
91
91
|
|
|
92
92
|
// eslint-disable-next-line functional/no-conditional-statements
|
|
93
93
|
if (expectedOpResult !== undefined) {
|
|
94
|
-
|
|
94
|
+
assert.deepStrictEqual(opResult, expectedOpResult);
|
|
95
95
|
}
|
|
96
96
|
await compareToFirstDbEntry({mongoFixtures, expectedResult, expectModificationTime, formatDates: true});
|
|
97
97
|
} catch (error) {
|
|
@@ -2,22 +2,22 @@ import {READERS} from '@natlibfi/fixura';
|
|
|
2
2
|
import mongoFixturesFactory from '@natlibfi/fixura-mongo';
|
|
3
3
|
import generateTests from '@natlibfi/fixugen';
|
|
4
4
|
import createDebugLogger from 'debug';
|
|
5
|
-
//import {handleError, compareToFirstDbEntry, compareToDbEntry, formatQueueItem, streamToString} from './testUtils';
|
|
6
|
-
import {getMongoOperator, handleError, compareToFirstDbEntry} from './testUtils';
|
|
5
|
+
//import {handleError, compareToFirstDbEntry, compareToDbEntry, formatQueueItem, streamToString} from './testUtils.js';
|
|
6
|
+
import {getMongoOperator, handleError, compareToFirstDbEntry} from './testUtils.js';
|
|
7
7
|
|
|
8
8
|
let mongoFixtures; // eslint-disable-line functional/no-let
|
|
9
9
|
const debug = createDebugLogger('@natlibfi/melinda-rest-api-commons/mongo:test:create-bulk');
|
|
10
10
|
|
|
11
11
|
generateTests({
|
|
12
12
|
callback,
|
|
13
|
-
path: [
|
|
13
|
+
path: [import.meta.dirname, '..', 'test-fixtures', 'mongo', 'create-bulk'],
|
|
14
14
|
recurse: false,
|
|
15
15
|
useMetadataFile: true,
|
|
16
16
|
fixura: {
|
|
17
17
|
failWhenNotFound: true,
|
|
18
18
|
reader: READERS.JSON
|
|
19
19
|
},
|
|
20
|
-
|
|
20
|
+
hooks: {
|
|
21
21
|
before: async () => {
|
|
22
22
|
//debug(`<< Before`);
|
|
23
23
|
await initMongofixtures();
|
|
@@ -40,7 +40,7 @@ generateTests({
|
|
|
40
40
|
async function initMongofixtures() {
|
|
41
41
|
mongoFixtures = await mongoFixturesFactory({
|
|
42
42
|
recurse: false,
|
|
43
|
-
rootPath: [
|
|
43
|
+
rootPath: [import.meta.dirname, '..', 'test-fixtures', 'mongo', 'create-bulk'],
|
|
44
44
|
gridFS: {bucketName: 'foobar'},
|
|
45
45
|
useObjectId: true
|
|
46
46
|
});
|
|
@@ -1,24 +1,24 @@
|
|
|
1
|
-
//import
|
|
1
|
+
//import assert from 'node:assert';
|
|
2
2
|
import {READERS} from '@natlibfi/fixura';
|
|
3
3
|
import mongoFixturesFactory from '@natlibfi/fixura-mongo';
|
|
4
4
|
import generateTests from '@natlibfi/fixugen';
|
|
5
5
|
import createDebugLogger from 'debug';
|
|
6
|
-
import {getMongoOperator, handleError, compareToFirstDbEntry} from './testUtils';
|
|
7
|
-
// import {handleError, compareToFirstDbEntry, compareToDbEntry, formatQueueItem, streamToString} from './testUtils';
|
|
6
|
+
import {getMongoOperator, handleError, compareToFirstDbEntry} from './testUtils.js';
|
|
7
|
+
// import {handleError, compareToFirstDbEntry, compareToDbEntry, formatQueueItem, streamToString} from './testUtils.js';
|
|
8
8
|
|
|
9
9
|
let mongoFixtures; // eslint-disable-line functional/no-let
|
|
10
10
|
const debug = createDebugLogger('@natlibfi/melinda-rest-api-commons/mongo:create-prio-test');
|
|
11
11
|
|
|
12
12
|
generateTests({
|
|
13
13
|
callback,
|
|
14
|
-
path: [
|
|
14
|
+
path: [import.meta.dirname, '..', 'test-fixtures', 'mongo', 'create-prio'],
|
|
15
15
|
recurse: false,
|
|
16
16
|
useMetadataFile: true,
|
|
17
17
|
fixura: {
|
|
18
18
|
failWhenNotFound: true,
|
|
19
19
|
reader: READERS.JSON
|
|
20
20
|
},
|
|
21
|
-
|
|
21
|
+
hooks: {
|
|
22
22
|
before: async () => {
|
|
23
23
|
//debug(`<< Before`);
|
|
24
24
|
await initMongofixtures();
|
|
@@ -41,7 +41,7 @@ generateTests({
|
|
|
41
41
|
async function initMongofixtures() {
|
|
42
42
|
mongoFixtures = await mongoFixturesFactory({
|
|
43
43
|
recurse: false,
|
|
44
|
-
rootPath: [
|
|
44
|
+
rootPath: [import.meta.dirname, '..', 'test-fixtures', 'mongo', 'create-prio'],
|
|
45
45
|
gridFS: {bucketName: 'foobar'},
|
|
46
46
|
useObjectId: true
|
|
47
47
|
});
|