@natlibfi/melinda-rest-api-commons 4.2.4-alpha.7 → 4.2.4
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/dist/mongo.js +15 -9
- package/dist/mongo.js.map +1 -1
- package/package.json +15 -14
- package/{dist → tests}/amqp.health.spec.js +17 -10
- package/tests/amqp.tests.spec.js +301 -0
- package/tests/helpers/conversion.spec.js +95 -0
- package/tests/helpers/fix.spec.js +41 -0
- package/tests/helpers/validation.spec.js +58 -0
- package/tests/mongo-add-blob-size.spec.js +92 -0
- package/tests/mongo-check-and-check-state.spec.js +105 -0
- package/tests/mongo-check-and-set-import-job-state.spec.js +104 -0
- package/tests/mongo-check-timeout.spec.js +104 -0
- package/tests/mongo-create-bulk.spec.js +93 -0
- package/tests/mongo-create-prio.spec.js +89 -0
- package/tests/mongo-get-one.spec.js +93 -0
- package/tests/mongo-get-stream.spec.js +112 -0
- package/tests/mongo-push-ids.spec.js +91 -0
- package/tests/mongo-push-messages.spec.js +89 -0
- package/tests/mongo-query-by-id.spec.js +106 -0
- package/tests/mongo-query.spec.js +98 -0
- package/tests/mongo-read-content.spec.js +115 -0
- package/tests/mongo-remove.spec.js +110 -0
- package/tests/mongo-set-blob-size.spec.js +89 -0
- package/tests/mongo-set-import-job-state.spec.js +92 -0
- package/tests/mongo-set-operation.spec.js +92 -0
- package/tests/mongo-set-operations.spec.js +91 -0
- package/tests/mongo-set-state.spec.js +92 -0
- package/{dist → tests}/mongoLog.spec.js +22 -22
- package/tests/testUtils.js +102 -0
- package/dist/amqp.health.spec.js.map +0 -1
- package/dist/amqp.tests.spec.js +0 -310
- package/dist/amqp.tests.spec.js.map +0 -1
- package/dist/helpers/conversion.spec.js +0 -88
- package/dist/helpers/conversion.spec.js.map +0 -1
- package/dist/helpers/fix.spec.js +0 -46
- package/dist/helpers/fix.spec.js.map +0 -1
- package/dist/helpers/validation.spec.js +0 -47
- package/dist/helpers/validation.spec.js.map +0 -1
- package/dist/mongo.spec.js +0 -768
- package/dist/mongo.spec.js.map +0 -1
- package/dist/mongoLog.spec.js.map +0 -1
package/dist/amqp.tests.spec.js
DELETED
|
@@ -1,310 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
var _chai = require("chai");
|
|
5
|
-
var _fixura = require("@natlibfi/fixura");
|
|
6
|
-
var _debug = _interopRequireDefault(require("debug"));
|
|
7
|
-
var _fixugen = _interopRequireDefault(require("@natlibfi/fixugen"));
|
|
8
|
-
var _index = require("./index");
|
|
9
|
-
var _melindaCommons = require("@natlibfi/melinda-commons");
|
|
10
|
-
var _util = require("util");
|
|
11
|
-
const setTimeoutPromise = (0, _util.promisify)(setTimeout);
|
|
12
|
-
const debug = (0, _debug.default)('@natlibfi/melinda-rest-api-commons:amqp:test');
|
|
13
|
-
//const debugData = debug.extend('data');
|
|
14
|
-
|
|
15
|
-
const testData = {
|
|
16
|
-
queue: 'TESTQUEUE',
|
|
17
|
-
correlationId: 'aaaaaaaa-0000-aaaa-0000-000000000000',
|
|
18
|
-
data: {
|
|
19
|
-
'leader': '02518cam a2200745zi 4500',
|
|
20
|
-
'fields': [{
|
|
21
|
-
'tag': '001',
|
|
22
|
-
'value': '000019640'
|
|
23
|
-
}]
|
|
24
|
-
}
|
|
25
|
-
};
|
|
26
|
-
debug(`Testing amqp against a local AMQP instance - we'll need some kind of mockup for this`);
|
|
27
|
-
const amqpUrl = 'amqp://127.0.0.1:5672/';
|
|
28
|
-
// eslint-disable-next-line functional/no-let
|
|
29
|
-
let amqpOperator;
|
|
30
|
-
(0, _fixugen.default)({
|
|
31
|
-
callback,
|
|
32
|
-
path: [__dirname, '..', 'test-fixtures', 'amqp'],
|
|
33
|
-
recurse: false,
|
|
34
|
-
useMetadataFile: true,
|
|
35
|
-
fixura: {
|
|
36
|
-
failWhenNotFound: true,
|
|
37
|
-
reader: _fixura.READERS.JSON
|
|
38
|
-
},
|
|
39
|
-
mocha: {
|
|
40
|
-
before: async () => {
|
|
41
|
-
debug(`Connecting to ${amqpUrl}, with healthCheck running`);
|
|
42
|
-
amqpOperator = await (0, _index.amqpFactory)(amqpUrl, true);
|
|
43
|
-
},
|
|
44
|
-
beforeEach: async () => {
|
|
45
|
-
await amqpOperator.checkQueue({
|
|
46
|
-
queue: testData.queue,
|
|
47
|
-
toRecord: false,
|
|
48
|
-
purge: true
|
|
49
|
-
});
|
|
50
|
-
},
|
|
51
|
-
afterEach: async () => {
|
|
52
|
-
await amqpOperator.removeQueue(testData.queue);
|
|
53
|
-
},
|
|
54
|
-
after: async () => {
|
|
55
|
-
await amqpOperator.closeConnection();
|
|
56
|
-
//await testHeathCheck();
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
});
|
|
60
|
-
|
|
61
|
-
// eslint-disable-next-line max-statements
|
|
62
|
-
async function callback({
|
|
63
|
-
getFixture,
|
|
64
|
-
expectToFail = false,
|
|
65
|
-
expectedErrorStatus = '',
|
|
66
|
-
ackMessages = false,
|
|
67
|
-
nackMessages = false,
|
|
68
|
-
checkNextMessage = false,
|
|
69
|
-
checkQueueStyle = false,
|
|
70
|
-
queue = testData.queue,
|
|
71
|
-
sentToQueue,
|
|
72
|
-
expectedMessageCount,
|
|
73
|
-
removeQueue = false,
|
|
74
|
-
expectedErrorMessage = undefined,
|
|
75
|
-
expectApiError = false,
|
|
76
|
-
expectFalseCheckResult = false
|
|
77
|
-
}) {
|
|
78
|
-
try {
|
|
79
|
-
await sendMessagesToQueue();
|
|
80
|
-
await ackOrNackMessages();
|
|
81
|
-
await checkQueue();
|
|
82
|
-
await queueRemoval();
|
|
83
|
-
const messageCount = await amqpOperator.checkQueue({
|
|
84
|
-
queue,
|
|
85
|
-
style: 'messages'
|
|
86
|
-
});
|
|
87
|
-
debug(`MessageCount: ${messageCount}`);
|
|
88
|
-
(0, _chai.expect)(messageCount).to.eql(expectedMessageCount);
|
|
89
|
-
if (checkNextMessage) {
|
|
90
|
-
const {
|
|
91
|
-
headers,
|
|
92
|
-
records
|
|
93
|
-
} = await queueCheckNextMessage();
|
|
94
|
-
const nextMessage = {
|
|
95
|
-
headers,
|
|
96
|
-
records
|
|
97
|
-
};
|
|
98
|
-
const expectedNextMessage = getFixture('expectedMessage.json');
|
|
99
|
-
(0, _chai.expect)(nextMessage).to.eql(expectedNextMessage);
|
|
100
|
-
return;
|
|
101
|
-
}
|
|
102
|
-
} catch (error) {
|
|
103
|
-
if (!expectToFail) {
|
|
104
|
-
throw error;
|
|
105
|
-
}
|
|
106
|
-
(0, _chai.expect)(expectToFail, 'This is expected to fail').to.equal(true);
|
|
107
|
-
testErrors(error);
|
|
108
|
-
}
|
|
109
|
-
function testErrors(error) {
|
|
110
|
-
if (expectApiError) {
|
|
111
|
-
(0, _chai.expect)(error).to.be.instanceOf(_melindaCommons.Error);
|
|
112
|
-
debug(`We expected and got an ApiError`);
|
|
113
|
-
(0, _chai.expect)(error.status).to.equal(expectedErrorStatus);
|
|
114
|
-
if (expectedErrorMessage) {
|
|
115
|
-
(0, _chai.expect)(error.payload).to.eql(expectedErrorMessage);
|
|
116
|
-
return;
|
|
117
|
-
}
|
|
118
|
-
return;
|
|
119
|
-
}
|
|
120
|
-
(0, _chai.expect)(error).not.to.be.instanceOf(_melindaCommons.Error);
|
|
121
|
-
debug(`We expected and got an non-ApiError`);
|
|
122
|
-
debug(`Error is a ${error.constructor.name}`);
|
|
123
|
-
}
|
|
124
|
-
function queueRemoval() {
|
|
125
|
-
if (removeQueue) {
|
|
126
|
-
return amqpOperator.removeQueue(removeQueue);
|
|
127
|
-
}
|
|
128
|
-
return;
|
|
129
|
-
}
|
|
130
|
-
function queueCheckNextMessage() {
|
|
131
|
-
if (checkNextMessage) {
|
|
132
|
-
return amqpOperator.consumeOne(testData.queue, true);
|
|
133
|
-
}
|
|
134
|
-
return false;
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
// eslint-disable-next-line max-statements
|
|
138
|
-
async function checkQueue() {
|
|
139
|
-
debug(`checkQueueStyle: ${checkQueueStyle}`);
|
|
140
|
-
if (checkQueueStyle === 'oneToRecord') {
|
|
141
|
-
const result = await amqpOperator.checkQueue({
|
|
142
|
-
queue,
|
|
143
|
-
style: 'one',
|
|
144
|
-
toRecord: true,
|
|
145
|
-
purge: false
|
|
146
|
-
});
|
|
147
|
-
if (expectFalseCheckResult) {
|
|
148
|
-
(0, _chai.expect)(result).to.eql(false);
|
|
149
|
-
return;
|
|
150
|
-
}
|
|
151
|
-
(0, _chai.expect)(result).to.have.property('headers');
|
|
152
|
-
(0, _chai.expect)(result).to.have.property('records');
|
|
153
|
-
(0, _chai.expect)(result).to.have.property('messages');
|
|
154
|
-
(0, _chai.expect)(result.records.length).to.eql(1);
|
|
155
|
-
(0, _chai.expect)(result.messages.length).to.eql(1);
|
|
156
|
-
return;
|
|
157
|
-
}
|
|
158
|
-
if (checkQueueStyle === 'oneNotRecord') {
|
|
159
|
-
const result = await amqpOperator.checkQueue({
|
|
160
|
-
queue,
|
|
161
|
-
style: 'one',
|
|
162
|
-
toRecord: false,
|
|
163
|
-
purge: false
|
|
164
|
-
});
|
|
165
|
-
const {
|
|
166
|
-
fields
|
|
167
|
-
} = result;
|
|
168
|
-
if (expectFalseCheckResult) {
|
|
169
|
-
(0, _chai.expect)(result).to.eql(false);
|
|
170
|
-
return;
|
|
171
|
-
}
|
|
172
|
-
(0, _chai.expect)(fields).to.have.property('deliveryTag');
|
|
173
|
-
(0, _chai.expect)(fields).to.have.property('exchange');
|
|
174
|
-
(0, _chai.expect)(fields).to.have.property('messageCount');
|
|
175
|
-
(0, _chai.expect)(fields).to.have.property('redelivered');
|
|
176
|
-
(0, _chai.expect)(fields).to.have.property('routingKey');
|
|
177
|
-
(0, _chai.expect)(typeof fields.deliveryTag).to.be.eql('number');
|
|
178
|
-
(0, _chai.expect)(typeof fields.messageCount).to.be.eql('number');
|
|
179
|
-
(0, _chai.expect)(typeof fields.redelivered).to.be.eql('boolean');
|
|
180
|
-
(0, _chai.expect)(typeof fields.routingKey).to.be.eql('string');
|
|
181
|
-
return;
|
|
182
|
-
}
|
|
183
|
-
if (checkQueueStyle === 'basicToRecord') {
|
|
184
|
-
const result = await amqpOperator.checkQueue({
|
|
185
|
-
queue,
|
|
186
|
-
style: 'basic',
|
|
187
|
-
toRecord: true,
|
|
188
|
-
purge: false
|
|
189
|
-
});
|
|
190
|
-
if (expectFalseCheckResult) {
|
|
191
|
-
(0, _chai.expect)(result).to.eql(false);
|
|
192
|
-
return;
|
|
193
|
-
}
|
|
194
|
-
(0, _chai.expect)(result).to.have.property('headers');
|
|
195
|
-
(0, _chai.expect)(result).to.have.property('records');
|
|
196
|
-
(0, _chai.expect)(result).to.have.property('messages');
|
|
197
|
-
(0, _chai.expect)(result.records.length).to.eql(3);
|
|
198
|
-
(0, _chai.expect)(result.messages.length).to.eql(3);
|
|
199
|
-
const expectedResult = getFixture('expectedResult.json');
|
|
200
|
-
(0, _chai.expect)(result.records).to.eql(expectedResult);
|
|
201
|
-
return;
|
|
202
|
-
}
|
|
203
|
-
if (checkQueueStyle === 'basicNotRecord') {
|
|
204
|
-
const result = await amqpOperator.checkQueue({
|
|
205
|
-
queue,
|
|
206
|
-
style: 'basic',
|
|
207
|
-
toRecord: false,
|
|
208
|
-
purge: false
|
|
209
|
-
});
|
|
210
|
-
if (expectFalseCheckResult) {
|
|
211
|
-
(0, _chai.expect)(result).to.eql(false);
|
|
212
|
-
return;
|
|
213
|
-
}
|
|
214
|
-
(0, _chai.expect)(result).to.have.property('headers');
|
|
215
|
-
(0, _chai.expect)(result).to.have.property('messages');
|
|
216
|
-
(0, _chai.expect)(result.messages.length).to.eql(3);
|
|
217
|
-
const [{
|
|
218
|
-
fields
|
|
219
|
-
}] = result.messages;
|
|
220
|
-
(0, _chai.expect)(fields).to.have.property('deliveryTag');
|
|
221
|
-
(0, _chai.expect)(fields).to.have.property('exchange');
|
|
222
|
-
(0, _chai.expect)(fields).to.have.property('messageCount');
|
|
223
|
-
(0, _chai.expect)(fields).to.have.property('redelivered');
|
|
224
|
-
(0, _chai.expect)(fields).to.have.property('routingKey');
|
|
225
|
-
(0, _chai.expect)(typeof fields.deliveryTag).to.be.eql('number');
|
|
226
|
-
(0, _chai.expect)(typeof fields.messageCount).to.be.eql('number');
|
|
227
|
-
(0, _chai.expect)(typeof fields.redelivered).to.be.eql('boolean');
|
|
228
|
-
(0, _chai.expect)(typeof fields.routingKey).to.be.eql('string');
|
|
229
|
-
return;
|
|
230
|
-
}
|
|
231
|
-
if (checkQueueStyle === 'purge') {
|
|
232
|
-
return amqpOperator.checkQueue({
|
|
233
|
-
queue,
|
|
234
|
-
style: 'messages',
|
|
235
|
-
purge: true
|
|
236
|
-
});
|
|
237
|
-
}
|
|
238
|
-
if (checkQueueStyle === 'foobar') {
|
|
239
|
-
return amqpOperator.checkQueue({
|
|
240
|
-
queue,
|
|
241
|
-
style: 'foobar',
|
|
242
|
-
toRecord: false,
|
|
243
|
-
purge: false
|
|
244
|
-
});
|
|
245
|
-
}
|
|
246
|
-
return false;
|
|
247
|
-
}
|
|
248
|
-
async function ackOrNackMessages() {
|
|
249
|
-
if (ackMessages) {
|
|
250
|
-
const message = await amqpOperator.consumeOne(testData.queue, false);
|
|
251
|
-
await amqpOperator.ackMessages([message]);
|
|
252
|
-
return setTimeoutPromise(10);
|
|
253
|
-
}
|
|
254
|
-
if (nackMessages) {
|
|
255
|
-
const message = await amqpOperator.consumeOne(testData.queue, false);
|
|
256
|
-
await amqpOperator.nackMessages([message]);
|
|
257
|
-
return setTimeoutPromise(10);
|
|
258
|
-
}
|
|
259
|
-
return;
|
|
260
|
-
}
|
|
261
|
-
async function sendMessagesToQueue() {
|
|
262
|
-
if (sentToQueue) {
|
|
263
|
-
const messages = getFixture('input.json');
|
|
264
|
-
// {queue, correlationId, headers, data}
|
|
265
|
-
|
|
266
|
-
const promises = messages.map(message => amqpOperator.sendToQueue(message));
|
|
267
|
-
await Promise.all(promises);
|
|
268
|
-
return setTimeoutPromise(10);
|
|
269
|
-
}
|
|
270
|
-
return;
|
|
271
|
-
}
|
|
272
|
-
}
|
|
273
|
-
|
|
274
|
-
/*
|
|
275
|
-
function testHeathCheck() {
|
|
276
|
-
return it('expects healthCheck', async () => {
|
|
277
|
-
|
|
278
|
-
const amqpOperator2 = await amqpFactory(amqpUrl, true);
|
|
279
|
-
try {
|
|
280
|
-
|
|
281
|
-
debug(`**********`);
|
|
282
|
-
await testHealthCheckLoopWorking(amqpOperator2);
|
|
283
|
-
|
|
284
|
-
debug(`**********`);
|
|
285
|
-
await testHealthCheckLoopErroring(amqpOperator2);
|
|
286
|
-
} catch (error) {
|
|
287
|
-
debug(error);
|
|
288
|
-
expect(error).to.eql('');
|
|
289
|
-
} finally {
|
|
290
|
-
amqpOperator2.closeConnection();
|
|
291
|
-
}
|
|
292
|
-
|
|
293
|
-
async function testHealthCheckLoopWorking(amqpOperator) {
|
|
294
|
-
debug(`Testing healthCheckLoop for ${amqpOperator}`);
|
|
295
|
-
debug(`Waiting 0.5s and expecting healthCheckLoop to work`);
|
|
296
|
-
await setTimeoutPromise('500');
|
|
297
|
-
debug(`Amqp Operator should have been alive.`);
|
|
298
|
-
}
|
|
299
|
-
|
|
300
|
-
async function testHealthCheckLoopErroring(amqpOperator) {
|
|
301
|
-
debug(`Testing healthCheckLoop with closed channel`);
|
|
302
|
-
amqpOperator.closeChannel();
|
|
303
|
-
debug(`Waiting 0.5s and expecting healthCheckLoop to throw error`);
|
|
304
|
-
await setTimeoutPromise('500');
|
|
305
|
-
debug(`amqpOperator should have errored`);
|
|
306
|
-
}
|
|
307
|
-
});
|
|
308
|
-
}
|
|
309
|
-
*/
|
|
310
|
-
//# sourceMappingURL=amqp.tests.spec.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"amqp.tests.spec.js","names":["_chai","require","_fixura","_debug","_interopRequireDefault","_fixugen","_index","_melindaCommons","_util","setTimeoutPromise","promisify","setTimeout","debug","createDebugLogger","testData","queue","correlationId","data","amqpUrl","amqpOperator","generateTests","callback","path","__dirname","recurse","useMetadataFile","fixura","failWhenNotFound","reader","READERS","JSON","mocha","before","amqpFactory","beforeEach","checkQueue","toRecord","purge","afterEach","removeQueue","after","closeConnection","getFixture","expectToFail","expectedErrorStatus","ackMessages","nackMessages","checkNextMessage","checkQueueStyle","sentToQueue","expectedMessageCount","expectedErrorMessage","undefined","expectApiError","expectFalseCheckResult","sendMessagesToQueue","ackOrNackMessages","queueRemoval","messageCount","style","expect","to","eql","headers","records","queueCheckNextMessage","nextMessage","expectedNextMessage","error","equal","testErrors","be","instanceOf","ApiError","status","payload","not","constructor","name","consumeOne","result","have","property","length","messages","fields","deliveryTag","redelivered","routingKey","expectedResult","message","promises","map","sendToQueue","Promise","all"],"sources":["../src/amqp.tests.spec.js"],"sourcesContent":["import {expect} from 'chai';\nimport {READERS} from '@natlibfi/fixura';\nimport createDebugLogger from 'debug';\nimport generateTests from '@natlibfi/fixugen';\nimport {amqpFactory} from './index';\nimport {Error as ApiError} from '@natlibfi/melinda-commons';\nimport {promisify} from 'util';\n\nconst setTimeoutPromise = promisify(setTimeout);\nconst debug = createDebugLogger('@natlibfi/melinda-rest-api-commons:amqp:test');\n//const debugData = debug.extend('data');\n\nconst testData = {\n queue: 'TESTQUEUE',\n correlationId: 'aaaaaaaa-0000-aaaa-0000-000000000000',\n data: {'leader': '02518cam a2200745zi 4500', 'fields': [{'tag': '001', 'value': '000019640'}]}\n};\n\ndebug(`Testing amqp against a local AMQP instance - we'll need some kind of mockup for this`);\nconst amqpUrl = 'amqp://127.0.0.1:5672/';\n// eslint-disable-next-line functional/no-let\nlet amqpOperator;\n\ngenerateTests({\n callback,\n path: [__dirname, '..', 'test-fixtures', 'amqp'],\n recurse: false,\n useMetadataFile: true,\n fixura: {\n failWhenNotFound: true,\n reader: READERS.JSON\n },\n mocha: {\n before: async () => {\n debug(`Connecting to ${amqpUrl}, with healthCheck running`);\n amqpOperator = await amqpFactory(amqpUrl, true);\n },\n beforeEach: async () => {\n await amqpOperator.checkQueue({queue: testData.queue, toRecord: false, purge: true});\n },\n afterEach: async () => {\n await amqpOperator.removeQueue(testData.queue);\n },\n after: async () => {\n await amqpOperator.closeConnection();\n //await testHeathCheck();\n }\n }\n});\n\n// eslint-disable-next-line max-statements\nasync function callback({\n getFixture,\n expectToFail = false,\n expectedErrorStatus = '',\n ackMessages = false,\n nackMessages = false,\n checkNextMessage = false,\n checkQueueStyle = false,\n queue = testData.queue,\n sentToQueue,\n expectedMessageCount,\n removeQueue = false,\n expectedErrorMessage = undefined,\n expectApiError = false,\n expectFalseCheckResult = false\n}) {\n try {\n await sendMessagesToQueue();\n\n await ackOrNackMessages();\n\n await checkQueue();\n\n await queueRemoval();\n\n const messageCount = await amqpOperator.checkQueue({queue, style: 'messages'});\n debug(`MessageCount: ${messageCount}`);\n expect(messageCount).to.eql(expectedMessageCount);\n\n if (checkNextMessage) {\n const {headers, records} = await queueCheckNextMessage();\n const nextMessage = {headers, records};\n const expectedNextMessage = getFixture('expectedMessage.json');\n expect(nextMessage).to.eql(expectedNextMessage);\n return;\n }\n\n } catch (error) {\n if (!expectToFail) {\n throw error;\n }\n expect(expectToFail, 'This is expected to fail').to.equal(true);\n testErrors(error);\n }\n\n function testErrors(error) {\n\n if (expectApiError) {\n expect(error).to.be.instanceOf(ApiError);\n debug(`We expected and got an ApiError`);\n expect(error.status).to.equal(expectedErrorStatus);\n\n if (expectedErrorMessage) {\n expect(error.payload).to.eql(expectedErrorMessage);\n return;\n }\n\n return;\n }\n expect(error).not.to.be.instanceOf(ApiError);\n debug(`We expected and got an non-ApiError`);\n debug(`Error is a ${error.constructor.name}`);\n }\n\n function queueRemoval() {\n if (removeQueue) {\n return amqpOperator.removeQueue(removeQueue);\n }\n\n return;\n }\n\n function queueCheckNextMessage() {\n if (checkNextMessage) {\n return amqpOperator.consumeOne(testData.queue, true);\n }\n\n return false;\n }\n\n // eslint-disable-next-line max-statements\n async function checkQueue() {\n debug(`checkQueueStyle: ${checkQueueStyle}`);\n\n if (checkQueueStyle === 'oneToRecord') {\n const result = await amqpOperator.checkQueue({queue, style: 'one', toRecord: true, purge: false});\n\n if (expectFalseCheckResult) {\n expect(result).to.eql(false);\n return;\n }\n\n expect(result).to.have.property('headers');\n expect(result).to.have.property('records');\n expect(result).to.have.property('messages');\n expect(result.records.length).to.eql(1);\n expect(result.messages.length).to.eql(1);\n\n return;\n }\n\n if (checkQueueStyle === 'oneNotRecord') {\n const result = await amqpOperator.checkQueue({queue, style: 'one', toRecord: false, purge: false});\n const {fields} = result;\n\n if (expectFalseCheckResult) {\n expect(result).to.eql(false);\n return;\n }\n\n expect(fields).to.have.property('deliveryTag');\n expect(fields).to.have.property('exchange');\n expect(fields).to.have.property('messageCount');\n expect(fields).to.have.property('redelivered');\n expect(fields).to.have.property('routingKey');\n expect(typeof fields.deliveryTag).to.be.eql('number');\n expect(typeof fields.messageCount).to.be.eql('number');\n expect(typeof fields.redelivered).to.be.eql('boolean');\n expect(typeof fields.routingKey).to.be.eql('string');\n\n return;\n }\n\n if (checkQueueStyle === 'basicToRecord') {\n const result = await amqpOperator.checkQueue({queue, style: 'basic', toRecord: true, purge: false});\n\n if (expectFalseCheckResult) {\n expect(result).to.eql(false);\n return;\n }\n\n expect(result).to.have.property('headers');\n expect(result).to.have.property('records');\n expect(result).to.have.property('messages');\n expect(result.records.length).to.eql(3);\n expect(result.messages.length).to.eql(3);\n const expectedResult = getFixture('expectedResult.json');\n expect(result.records).to.eql(expectedResult);\n\n return;\n }\n\n if (checkQueueStyle === 'basicNotRecord') {\n const result = await amqpOperator.checkQueue({queue, style: 'basic', toRecord: false, purge: false});\n\n if (expectFalseCheckResult) {\n expect(result).to.eql(false);\n return;\n }\n\n expect(result).to.have.property('headers');\n expect(result).to.have.property('messages');\n expect(result.messages.length).to.eql(3);\n\n const [{fields}] = result.messages;\n\n expect(fields).to.have.property('deliveryTag');\n expect(fields).to.have.property('exchange');\n expect(fields).to.have.property('messageCount');\n expect(fields).to.have.property('redelivered');\n expect(fields).to.have.property('routingKey');\n\n expect(typeof fields.deliveryTag).to.be.eql('number');\n expect(typeof fields.messageCount).to.be.eql('number');\n expect(typeof fields.redelivered).to.be.eql('boolean');\n expect(typeof fields.routingKey).to.be.eql('string');\n\n return;\n }\n\n if (checkQueueStyle === 'purge') {\n return amqpOperator.checkQueue({queue, style: 'messages', purge: true});\n }\n\n if (checkQueueStyle === 'foobar') {\n return amqpOperator.checkQueue({queue, style: 'foobar', toRecord: false, purge: false});\n }\n\n return false;\n }\n\n async function ackOrNackMessages() {\n if (ackMessages) {\n const message = await amqpOperator.consumeOne(testData.queue, false);\n await amqpOperator.ackMessages([message]);\n\n return setTimeoutPromise(10);\n }\n\n if (nackMessages) {\n const message = await amqpOperator.consumeOne(testData.queue, false);\n await amqpOperator.nackMessages([message]);\n\n return setTimeoutPromise(10);\n }\n\n return;\n }\n\n async function sendMessagesToQueue() {\n if (sentToQueue) {\n const messages = getFixture('input.json');\n // {queue, correlationId, headers, data}\n\n const promises = messages.map(message => amqpOperator.sendToQueue(message));\n await Promise.all(promises);\n\n return setTimeoutPromise(10);\n }\n\n return;\n }\n}\n\n/*\nfunction testHeathCheck() {\n return it('expects healthCheck', async () => {\n\n const amqpOperator2 = await amqpFactory(amqpUrl, true);\n try {\n\n debug(`**********`);\n await testHealthCheckLoopWorking(amqpOperator2);\n\n debug(`**********`);\n await testHealthCheckLoopErroring(amqpOperator2);\n } catch (error) {\n debug(error);\n expect(error).to.eql('');\n } finally {\n amqpOperator2.closeConnection();\n }\n\n async function testHealthCheckLoopWorking(amqpOperator) {\n debug(`Testing healthCheckLoop for ${amqpOperator}`);\n debug(`Waiting 0.5s and expecting healthCheckLoop to work`);\n await setTimeoutPromise('500');\n debug(`Amqp Operator should have been alive.`);\n }\n\n async function testHealthCheckLoopErroring(amqpOperator) {\n debug(`Testing healthCheckLoop with closed channel`);\n amqpOperator.closeChannel();\n debug(`Waiting 0.5s and expecting healthCheckLoop to throw error`);\n await setTimeoutPromise('500');\n debug(`amqpOperator should have errored`);\n }\n });\n}\n*/\n"],"mappings":";;;AAAA,IAAAA,KAAA,GAAAC,OAAA;AACA,IAAAC,OAAA,GAAAD,OAAA;AACA,IAAAE,MAAA,GAAAC,sBAAA,CAAAH,OAAA;AACA,IAAAI,QAAA,GAAAD,sBAAA,CAAAH,OAAA;AACA,IAAAK,MAAA,GAAAL,OAAA;AACA,IAAAM,eAAA,GAAAN,OAAA;AACA,IAAAO,KAAA,GAAAP,OAAA;AAEA,MAAMQ,iBAAiB,GAAG,IAAAC,eAAS,EAACC,UAAU,CAAC;AAC/C,MAAMC,KAAK,GAAG,IAAAC,cAAiB,EAAC,8CAA8C,CAAC;AAC/E;;AAEA,MAAMC,QAAQ,GAAG;EACfC,KAAK,EAAE,WAAW;EAClBC,aAAa,EAAE,sCAAsC;EACrDC,IAAI,EAAE;IAAC,QAAQ,EAAE,0BAA0B;IAAE,QAAQ,EAAE,CAAC;MAAC,KAAK,EAAE,KAAK;MAAE,OAAO,EAAE;IAAW,CAAC;EAAC;AAC/F,CAAC;AAEDL,KAAK,CAAC,sFAAsF,CAAC;AAC7F,MAAMM,OAAO,GAAG,wBAAwB;AACxC;AACA,IAAIC,YAAY;AAEhB,IAAAC,gBAAa,EAAC;EACZC,QAAQ;EACRC,IAAI,EAAE,CAACC,SAAS,EAAE,IAAI,EAAE,eAAe,EAAE,MAAM,CAAC;EAChDC,OAAO,EAAE,KAAK;EACdC,eAAe,EAAE,IAAI;EACrBC,MAAM,EAAE;IACNC,gBAAgB,EAAE,IAAI;IACtBC,MAAM,EAAEC,eAAO,CAACC;EAClB,CAAC;EACDC,KAAK,EAAE;IACLC,MAAM,EAAE,MAAAA,CAAA,KAAY;MAClBpB,KAAK,CAAC,iBAAiBM,OAAO,4BAA4B,CAAC;MAC3DC,YAAY,GAAG,MAAM,IAAAc,kBAAW,EAACf,OAAO,EAAE,IAAI,CAAC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WAAW,EAAE;MACf,MAAMmC,QAAQ,GAAG1C,UAAU,CAAC,YAAY,CAAC;MACzC;;MAEA,MAAMiD,QAAQ,GAAGP,QAAQ,CAACQ,GAAG,CAACF,OAAO,IAAIvE,YAAY,CAAC0E,WAAW,CAACH,OAAO,CAAC,CAAC;MAC3E,MAAMI,OAAO,CAACC,GAAG,CAACJ,QAAQ,CAAC;MAE3B,OAAOlF,iBAAiB,CAAC,EAAE,CAAC;IAC9B;IAEA;EACF;AACF;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA","ignoreList":[]}
|
|
@@ -1,88 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
var _chai = require("chai");
|
|
5
|
-
var _fixura = _interopRequireDefault(require("@natlibfi/fixura"));
|
|
6
|
-
var _marcRecord = require("@natlibfi/marc-record");
|
|
7
|
-
var _melindaCommons = require("@natlibfi/melinda-commons");
|
|
8
|
-
var _conversion = _interopRequireDefault(require("./conversion"));
|
|
9
|
-
var _constants = require("../constants");
|
|
10
|
-
describe('services/conversion', () => {
|
|
11
|
-
const {
|
|
12
|
-
getFixture
|
|
13
|
-
} = (0, _fixura.default)({
|
|
14
|
-
root: [__dirname, '..', '..', 'test-fixtures', 'conversion']
|
|
15
|
-
});
|
|
16
|
-
const conversionService = (0, _conversion.default)();
|
|
17
|
-
const marcRecord = new _marcRecord.MarcRecord(JSON.parse(getFixture({
|
|
18
|
-
components: ['json1']
|
|
19
|
-
})), {
|
|
20
|
-
subfieldValues: false
|
|
21
|
-
});
|
|
22
|
-
const marcXml = getFixture({
|
|
23
|
-
components: ['marcxml1']
|
|
24
|
-
});
|
|
25
|
-
const iso2709 = getFixture({
|
|
26
|
-
components: ['iso2709_1']
|
|
27
|
-
});
|
|
28
|
-
const json = getFixture({
|
|
29
|
-
components: ['json1']
|
|
30
|
-
});
|
|
31
|
-
const alephSeq = getFixture({
|
|
32
|
-
components: ['aleph_sequential']
|
|
33
|
-
});
|
|
34
|
-
describe('factory', () => {
|
|
35
|
-
it('Should create the expected object', () => {
|
|
36
|
-
const service = (0, _conversion.default)();
|
|
37
|
-
(0, _chai.expect)(service).to.be.an('object').and.respondTo('serialize').respondTo('unserialize');
|
|
38
|
-
});
|
|
39
|
-
});
|
|
40
|
-
describe('#serialize', () => {
|
|
41
|
-
it('Should throw because of unsupported format', () => {
|
|
42
|
-
(0, _chai.expect)(conversionService.serialize).to.throw();
|
|
43
|
-
});
|
|
44
|
-
it('Should serialize to MARCXML', () => {
|
|
45
|
-
const data = conversionService.serialize(marcRecord, _constants.CONVERSION_FORMATS.MARCXML);
|
|
46
|
-
(0, _chai.expect)(data).to.equal(marcXml);
|
|
47
|
-
});
|
|
48
|
-
it('Should serialize to ISO2709', () => {
|
|
49
|
-
const data = conversionService.serialize(marcRecord, _constants.CONVERSION_FORMATS.ISO2709);
|
|
50
|
-
(0, _chai.expect)(data).to.equal(iso2709);
|
|
51
|
-
});
|
|
52
|
-
it('Should serialize to JSON', () => {
|
|
53
|
-
const data = conversionService.serialize(marcRecord, _constants.CONVERSION_FORMATS.JSON);
|
|
54
|
-
(0, _chai.expect)(data).to.equal(json);
|
|
55
|
-
});
|
|
56
|
-
it('Should serialize to aleph sequential', () => {
|
|
57
|
-
const data = conversionService.serialize(marcRecord, _constants.CONVERSION_FORMATS.ALEPHSEQ);
|
|
58
|
-
(0, _chai.expect)(data).to.equal(alephSeq);
|
|
59
|
-
});
|
|
60
|
-
});
|
|
61
|
-
describe('#unserialize', () => {
|
|
62
|
-
it('Should throw because of unsupported format', () => {
|
|
63
|
-
(0, _chai.expect)(conversionService.unserialize).to.throw();
|
|
64
|
-
});
|
|
65
|
-
it('Should unserialize from MARCXML', async () => {
|
|
66
|
-
const record = await conversionService.unserialize(marcXml, _constants.CONVERSION_FORMATS.MARCXML);
|
|
67
|
-
(0, _chai.expect)(record.equalsTo(marcRecord)).to.equal(true);
|
|
68
|
-
});
|
|
69
|
-
it('Should unserialize from ISO2709', () => {
|
|
70
|
-
const record = conversionService.unserialize(iso2709, _constants.CONVERSION_FORMATS.ISO2709);
|
|
71
|
-
(0, _chai.expect)(record.equalsTo(marcRecord)).to.equal(true);
|
|
72
|
-
});
|
|
73
|
-
it('Should unserialize from JSON', () => {
|
|
74
|
-
const record = conversionService.unserialize(json, _constants.CONVERSION_FORMATS.JSON);
|
|
75
|
-
(0, _chai.expect)(record.equalsTo(marcRecord)).to.equal(true);
|
|
76
|
-
});
|
|
77
|
-
it('Should unserialize from Aleph sequential', () => {
|
|
78
|
-
const record = conversionService.unserialize(alephSeq, _constants.CONVERSION_FORMATS.ALEPHSEQ);
|
|
79
|
-
(0, _chai.expect)(record.equalsTo(marcRecord)).to.equal(true);
|
|
80
|
-
});
|
|
81
|
-
it('Should throw because the record could not be unserialized', () => {
|
|
82
|
-
(0, _chai.expect)(() => {
|
|
83
|
-
conversionService.unserialize('', _constants.CONVERSION_FORMATS.JSON);
|
|
84
|
-
}).to.throw(_melindaCommons.Error);
|
|
85
|
-
});
|
|
86
|
-
});
|
|
87
|
-
});
|
|
88
|
-
//# sourceMappingURL=conversion.spec.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"conversion.spec.js","names":["_chai","require","_fixura","_interopRequireDefault","_marcRecord","_melindaCommons","_conversion","_constants","describe","getFixture","fixtureFactory","root","__dirname","conversionService","createConversionService","marcRecord","MarcRecord","JSON","parse","components","subfieldValues","marcXml","iso2709","json","alephSeq","it","service","expect","to","be","an","and","respondTo","serialize","throw","data","CONVERSION_FORMATS","MARCXML","equal","ISO2709","ALEPHSEQ","unserialize","record","equalsTo","ConversionError"],"sources":["../../src/helpers/conversion.spec.js"],"sourcesContent":["\n\nimport {expect} from 'chai';\nimport fixtureFactory from '@natlibfi/fixura';\nimport {MarcRecord} from '@natlibfi/marc-record';\nimport {Error as ConversionError} from '@natlibfi/melinda-commons';\nimport createConversionService from './conversion';\nimport {CONVERSION_FORMATS} from '../constants';\n\ndescribe('services/conversion', () => {\n const {getFixture} = fixtureFactory({root: [\n __dirname,\n '..',\n '..',\n 'test-fixtures',\n 'conversion'\n ]});\n const conversionService = createConversionService();\n\n const marcRecord = new MarcRecord(JSON.parse(getFixture({components: ['json1']})), {subfieldValues: false});\n const marcXml = getFixture({components: ['marcxml1']});\n const iso2709 = getFixture({components: ['iso2709_1']});\n const json = getFixture({components: ['json1']});\n const alephSeq = getFixture({components: ['aleph_sequential']});\n\n\n describe('factory', () => {\n it('Should create the expected object', () => {\n const service = createConversionService();\n expect(service).to.be.an('object').and\n .respondTo('serialize')\n .respondTo('unserialize');\n });\n });\n\n describe('#serialize', () => {\n it('Should throw because of unsupported format', () => {\n expect(conversionService.serialize).to.throw();\n });\n\n it('Should serialize to MARCXML', () => {\n const data = conversionService.serialize(marcRecord, CONVERSION_FORMATS.MARCXML);\n expect(data).to.equal(marcXml);\n });\n\n it('Should serialize to ISO2709', () => {\n const data = conversionService.serialize(marcRecord, CONVERSION_FORMATS.ISO2709);\n expect(data).to.equal(iso2709);\n });\n\n it('Should serialize to JSON', () => {\n const data = conversionService.serialize(marcRecord, CONVERSION_FORMATS.JSON);\n expect(data).to.equal(json);\n });\n\n it('Should serialize to aleph sequential', () => {\n const data = conversionService.serialize(marcRecord, CONVERSION_FORMATS.ALEPHSEQ);\n expect(data).to.equal(alephSeq);\n });\n\n });\n\n describe('#unserialize', () => {\n it('Should throw because of unsupported format', () => {\n expect(conversionService.unserialize).to.throw();\n });\n\n it('Should unserialize from MARCXML', async () => {\n const record = await conversionService.unserialize(marcXml, CONVERSION_FORMATS.MARCXML);\n expect(record.equalsTo(marcRecord)).to.equal(true);\n });\n\n it('Should unserialize from ISO2709', () => {\n const record = conversionService.unserialize(iso2709, CONVERSION_FORMATS.ISO2709);\n expect(record.equalsTo(marcRecord)).to.equal(true);\n });\n\n it('Should unserialize from JSON', () => {\n const record = conversionService.unserialize(json, CONVERSION_FORMATS.JSON);\n expect(record.equalsTo(marcRecord)).to.equal(true);\n });\n\n it('Should unserialize from Aleph sequential', () => {\n const record = conversionService.unserialize(alephSeq, CONVERSION_FORMATS.ALEPHSEQ);\n expect(record.equalsTo(marcRecord)).to.equal(true);\n });\n\n\n it('Should throw because the record could not be unserialized', () => {\n expect(() => {\n conversionService.unserialize('', CONVERSION_FORMATS.JSON);\n }).to.throw(ConversionError);\n });\n });\n});\n"],"mappings":";;;AAEA,IAAAA,KAAA,GAAAC,OAAA;AACA,IAAAC,OAAA,GAAAC,sBAAA,CAAAF,OAAA;AACA,IAAAG,WAAA,GAAAH,OAAA;AACA,IAAAI,eAAA,GAAAJ,OAAA;AACA,IAAAK,WAAA,GAAAH,sBAAA,CAAAF,OAAA;AACA,IAAAM,UAAA,GAAAN,OAAA;AAEAO,QAAQ,CAAC,qBAAqB,EAAE,MAAM;EACpC,MAAM;IAACC;EAAU,CAAC,GAAG,IAAAC,eAAc,EAAC;IAACC,IAAI,EAAE,CACzCC,SAAS,EACT,IAAI,EACJ,IAAI,EACJ,eAAe,EACf,YAAY;EACb,CAAC,CAAC;EACH,MAAMC,iBAAiB,GAAG,IAAAC,mBAAuB,EAAC,CAAC;EAEnD,MAAMC,UAAU,GAAG,IAAIC,sBAAU,CAACC,IAAI,CAACC,KAAK,CAACT,UAAU,CAAC;IAACU,UAAU,EAAE,CAAC,OAAO;EAAC,CAAC,CAAC,CAAC,EAAE;IAACC,cAAc,EAAE;EAAK,CAAC,CAAC;EAC3G,MAAMC,OAAO,GAAGZ,UAAU,CAAC;IAACU,UAAU,EAAE,CAAC,UAAU;EAAC,CAAC,CAAC;EACtD,MAAMG,OAAO,GAAGb,UAAU,CAAC;IAACU,UAAU,EAAE,CAAC,WAAW;EAAC,CAAC,CAAC;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AAMiB,MAAM,GAAG7B,iBAAiB,CAAC4B,WAAW,CAAClB,IAAI,EAAEa,6BAAkB,CAACnB,IAAI,CAAC;MAC3E,IAAAU,YAAM,EAACe,MAAM,CAACC,QAAQ,CAAC5B,UAAU,CAAC,CAAC,CAACa,EAAE,CAACU,KAAK,CAAC,IAAI,CAAC;IACpD,CAAC,CAAC;IAEFb,EAAE,CAAC,0CAA0C,EAAE,MAAM;MACnD,MAAMiB,MAAM,GAAG7B,iBAAiB,CAAC4B,WAAW,CAACjB,QAAQ,EAAEY,6BAAkB,CAACI,QAAQ,CAAC;MACnF,IAAAb,YAAM,EAACe,MAAM,CAACC,QAAQ,CAAC5B,UAAU,CAAC,CAAC,CAACa,EAAE,CAACU,KAAK,CAAC,IAAI,CAAC;IACpD,CAAC,CAAC;IAGFb,EAAE,CAAC,2DAA2D,EAAE,MAAM;MACpE,IAAAE,YAAM,EAAC,MAAM;QACXd,iBAAiB,CAAC4B,WAAW,CAAC,EAAE,EAAEL,6BAAkB,CAACnB,IAAI,CAAC;MAC5D,CAAC,CAAC,CAACW,EAAE,CAACM,KAAK,CAACU,qBAAe,CAAC;IAC9B,CAAC,CAAC;EACJ,CAAC,CAAC;AACJ,CAAC,CAAC","ignoreList":[]}
|
package/dist/helpers/fix.spec.js
DELETED
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
var _chai = require("chai");
|
|
5
|
-
var _marcRecord = require("@natlibfi/marc-record");
|
|
6
|
-
var _fixura = require("@natlibfi/fixura");
|
|
7
|
-
var _fixugen = _interopRequireDefault(require("@natlibfi/fixugen"));
|
|
8
|
-
var _fix = require("./fix");
|
|
9
|
-
var fixSettings = _interopRequireWildcard(require("./fix-constants"));
|
|
10
|
-
var _debug = _interopRequireDefault(require("debug"));
|
|
11
|
-
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
12
|
-
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
13
|
-
// import inspect from 'util';
|
|
14
|
-
|
|
15
|
-
const debug = (0, _debug.default)('@natlibfi/melinda-rest-api-commons:fix:test');
|
|
16
|
-
const debugData = debug.extend('data');
|
|
17
|
-
(0, _fixugen.default)({
|
|
18
|
-
callback,
|
|
19
|
-
path: [__dirname, '..', '..', 'test-fixtures', 'fix'],
|
|
20
|
-
recurse: true,
|
|
21
|
-
useMetadataFile: true,
|
|
22
|
-
fixura: {
|
|
23
|
-
failWhenNotFound: false,
|
|
24
|
-
reader: _fixura.READERS.JSON
|
|
25
|
-
}
|
|
26
|
-
});
|
|
27
|
-
function callback({
|
|
28
|
-
getFixture,
|
|
29
|
-
settings = undefined
|
|
30
|
-
}) {
|
|
31
|
-
if (settings !== undefined && fixSettings[settings] === undefined) {
|
|
32
|
-
throw new Error(`There are no settings ${settings} defined!`);
|
|
33
|
-
}
|
|
34
|
-
const runSettings = fixSettings[settings] || settings;
|
|
35
|
-
const record = new _marcRecord.MarcRecord(getFixture('record.json'), {
|
|
36
|
-
subfieldValues: false
|
|
37
|
-
});
|
|
38
|
-
const expectedRecord = getFixture('expectedRecord.json');
|
|
39
|
-
debug(`Running fixer with settings ${settings}.`);
|
|
40
|
-
debugData(JSON.stringify(runSettings, null, 2));
|
|
41
|
-
const resultRecord = (0, _fix.fixRecord)(record, runSettings);
|
|
42
|
-
debugData(`Result: ${JSON.stringify(resultRecord)}`);
|
|
43
|
-
debugData(`Expected: ${JSON.stringify(expectedRecord)}`);
|
|
44
|
-
(0, _chai.expect)(resultRecord).to.eql(expectedRecord);
|
|
45
|
-
}
|
|
46
|
-
//# sourceMappingURL=fix.spec.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"fix.spec.js","names":["_chai","require","_marcRecord","_fixura","_fixugen","_interopRequireDefault","_fix","fixSettings","_interopRequireWildcard","_debug","_getRequireWildcardCache","e","WeakMap","r","t","__esModule","default","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","hasOwnProperty","call","i","set","debug","createDebugLogger","debugData","extend","generateTests","callback","path","__dirname","recurse","useMetadataFile","fixura","failWhenNotFound","reader","READERS","JSON","getFixture","settings","undefined","Error","runSettings","record","MarcRecord","subfieldValues","expectedRecord","stringify","resultRecord","fixRecord","expect","to","eql"],"sources":["../../src/helpers/fix.spec.js"],"sourcesContent":["import {expect} from 'chai';\nimport {MarcRecord} from '@natlibfi/marc-record';\nimport {READERS} from '@natlibfi/fixura';\nimport generateTests from '@natlibfi/fixugen';\nimport {fixRecord} from './fix';\nimport * as fixSettings from './fix-constants';\nimport createDebugLogger from 'debug';\n// import inspect from 'util';\n\nconst debug = createDebugLogger('@natlibfi/melinda-rest-api-commons:fix:test');\nconst debugData = debug.extend('data');\n\ngenerateTests({\n callback,\n path: [__dirname, '..', '..', 'test-fixtures', 'fix'],\n recurse: true,\n useMetadataFile: true,\n fixura: {\n failWhenNotFound: false,\n reader: READERS.JSON\n }\n});\n\nfunction callback({getFixture, settings = undefined}) {\n if (settings !== undefined && fixSettings[settings] === undefined) {\n throw new Error(`There are no settings ${settings} defined!`);\n }\n const runSettings = fixSettings[settings] || settings;\n\n const record = new MarcRecord(getFixture('record.json'), {subfieldValues: false});\n const expectedRecord = getFixture('expectedRecord.json');\n\n debug(`Running fixer with settings ${settings}.`);\n debugData(JSON.stringify(runSettings, null, 2));\n\n const resultRecord = fixRecord(record, runSettings);\n debugData(`Result: ${JSON.stringify(resultRecord)}`);\n debugData(`Expected: ${JSON.stringify(expectedRecord)}`);\n expect(resultRecord).to.eql(expectedRecord);\n\n}\n"],"mappings":";;;AAAA,IAAAA,KAAA,GAAAC,OAAA;AACA,IAAAC,WAAA,GAAAD,OAAA;AACA,IAAAE,OAAA,GAAAF,OAAA;AACA,IAAAG,QAAA,GAAAC,sBAAA,CAAAJ,OAAA;AACA,IAAAK,IAAA,GAAAL,OAAA;AACA,IAAAM,WAAA,GAAAC,uBAAA,CAAAP,OAAA;AACA,IAAAQ,MAAA,GAAAJ,sBAAA,CAAAJ,OAAA;AAAsC,SAAAS,yBAAAC,CAAA,6BAAAC,OAAA,mBAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAF,wBAAA,YAAAA,CAAAC,CAAA,WAAAA,CAAA,GAAAG,CAAA,GAAAD,CAAA,KAAAF,CAAA;AAAA,SAAAH,wBAAAG,CAAA,EAAAE,CAAA,SAAAA,CAAA,IAAAF,CAAA,IAAAA,CAAA,CAAAI,UAAA,SAAAJ,CAAA,eAAAA,CAAA,uBAAAA,CAAA,yBAAAA,CAAA,WAAAK,OAAA,EAAAL,CAAA,QAAAG,CAAA,GAAAJ,wBAAA,CAAAG,CAAA,OAAAC,CAAA,IAAAA,CAAA,CAAAG,GAAA,CAAAN,CAAA,UAAAG,CAAA,CAAAI,GAAA,CAAAP,CAAA,OAAAQ,CAAA,KAAAC,SAAA,UAAAC,CAAA,GAAAC,MAAA,CAAAC,cAAA,IAAAD,MAAA,CAAAE,wBAAA,WAAAC,CAAA,IAAAd,CAAA,oBAAAc,CAAA,OAAAC,cAAA,CAAAC,IAAA,CAAAhB,CAAA,EAAAc,CAAA,SAAAG,CAAA,GAAAP,CAAA,GAAAC,MAAA,CAAAE,wBAAA,CAAAb,CAAA,EAAAc,CAAA,UAAAG,CAAA,KAAAA,CAAA,CAAAV,GAAA,IA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W,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC;EAE/C,MAAMM,YAAY,GAAG,IAAAC,cAAS,EAACN,MAAM,EAAED,WAAW,CAAC;EACnDjB,SAAS,CAAC,aAAaY,IAAI,CAACU,SAAS,CAACC,YAAY,CAAC,EAAE,CAAC;EACtDvB,SAAS,CAAC,aAAaY,IAAI,CAACU,SAAS,CAACD,cAAc,CAAC,EAAE,CAAC;EACxD,IAAAI,YAAM,EAACF,YAAY,CAAC,CAACG,EAAE,CAACC,GAAG,CAACN,cAAc,CAAC;AAE7C","ignoreList":[]}
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
var _chai = require("chai");
|
|
5
|
-
var _fixura = _interopRequireWildcard(require("@natlibfi/fixura"));
|
|
6
|
-
var _marcRecord = require("@natlibfi/marc-record");
|
|
7
|
-
var _validation = _interopRequireDefault(require("./validation"));
|
|
8
|
-
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
9
|
-
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
10
|
-
describe('services/validate', () => {
|
|
11
|
-
const FIXTURES_PATH = [__dirname, '..', '..', 'test-fixtures', 'validation'];
|
|
12
|
-
const {
|
|
13
|
-
getFixture
|
|
14
|
-
} = (0, _fixura.default)({
|
|
15
|
-
root: FIXTURES_PATH,
|
|
16
|
-
reader: _fixura.READERS.JSON
|
|
17
|
-
});
|
|
18
|
-
describe('f003-fi-melinda', () => {
|
|
19
|
-
it('Should have failed: false', async () => {
|
|
20
|
-
const validator = await (0, _validation.default)();
|
|
21
|
-
const record = new _marcRecord.MarcRecord(getFixture({
|
|
22
|
-
components: ['in', 'f003-fi-melinda.json']
|
|
23
|
-
}));
|
|
24
|
-
const result = await validator(record.toObject());
|
|
25
|
-
const expected = getFixture({
|
|
26
|
-
components: ['out', 'f003-fi-melinda.json']
|
|
27
|
-
});
|
|
28
|
-
(0, _chai.expect)(result).to.eql(expected);
|
|
29
|
-
(0, _chai.expect)(result.failed).to.equal(false);
|
|
30
|
-
});
|
|
31
|
-
});
|
|
32
|
-
describe('f003-not-fi-melinda', () => {
|
|
33
|
-
it('Should have failed: true', async () => {
|
|
34
|
-
const validator = await (0, _validation.default)();
|
|
35
|
-
const record = new _marcRecord.MarcRecord(getFixture({
|
|
36
|
-
components: ['in', 'f003-not-fi-melinda.json']
|
|
37
|
-
}));
|
|
38
|
-
const result = await validator(record.toObject());
|
|
39
|
-
const expected = getFixture({
|
|
40
|
-
components: ['out', 'f003-not-fi-melinda.json']
|
|
41
|
-
});
|
|
42
|
-
(0, _chai.expect)(result).to.eql(expected);
|
|
43
|
-
(0, _chai.expect)(result.failed).to.equal(true);
|
|
44
|
-
});
|
|
45
|
-
});
|
|
46
|
-
});
|
|
47
|
-
//# sourceMappingURL=validation.spec.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"validation.spec.js","names":["_chai","require","_fixura","_interopRequireWildcard","_marcRecord","_validation","_interopRequireDefault","_getRequireWildcardCache","e","WeakMap","r","t","__esModule","default","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","hasOwnProperty","call","i","set","describe","FIXTURES_PATH","__dirname","getFixture","fixtureFactory","root","reader","READERS","JSON","it","validator","createValidator","record","MarcRecord","components","result","toObject","expected","expect","to","eql","failed","equal"],"sources":["../../src/helpers/validation.spec.js"],"sourcesContent":["import {expect} from 'chai';\nimport fixtureFactory, {READERS} from '@natlibfi/fixura';\nimport {MarcRecord} from '@natlibfi/marc-record';\nimport createValidator from './validation';\n\ndescribe('services/validate', () => {\n const FIXTURES_PATH = [\n __dirname,\n '..',\n '..',\n 'test-fixtures',\n 'validation'\n ];\n const {getFixture} = fixtureFactory({root: FIXTURES_PATH, reader: READERS.JSON});\n\n describe('f003-fi-melinda', () => {\n it('Should have failed: false', async () => {\n const validator = await createValidator();\n const record = new MarcRecord(getFixture({\n components: [\n 'in',\n 'f003-fi-melinda.json'\n ]\n }));\n const result = await validator(record.toObject());\n const expected = getFixture({\n components: [\n 'out',\n 'f003-fi-melinda.json'\n ]\n });\n expect(result).to.eql(expected);\n expect(result.failed).to.equal(false);\n });\n });\n\n describe('f003-not-fi-melinda', () => {\n it('Should have failed: true', async () => {\n const validator = await createValidator();\n const record = new MarcRecord(getFixture({\n components: [\n 'in',\n 'f003-not-fi-melinda.json'\n ]\n }));\n const result = await validator(record.toObject());\n const expected = getFixture({\n components: [\n 'out',\n 'f003-not-fi-melinda.json'\n ]\n });\n expect(result).to.eql(expected);\n expect(result.failed).to.equal(true);\n });\n });\n});\n\n"],"mappings":";;;AAAA,IAAAA,KAAA,GAAAC,OAAA;AACA,IAAAC,OAAA,GAAAC,uBAAA,CAAAF,OAAA;AACA,IAAAG,WAAA,GAAAH,OAAA;AACA,IAAAI,WAAA,GAAAC,sBAAA,CAAAL,OAAA;AAA2C,SAAAM,yBAAAC,CAAA,6BAAAC,OAAA,mBAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAF,wBAAA,YAAAA,CAAAC,CAAA,WAAAA,CAAA,GAAAG,CAAA,GAAAD,CAAA,KAAAF,CAAA;AAAA,SAAAL,wBAAAK,CAAA,EAAAE,CAAA,SAAAA,CAAA,IAAAF,CAAA,IAAAA,CAAA,CAAAI,UAAA,SA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