Skip to content

Commit

Permalink
Dev+hotfix (#140)
Browse files Browse the repository at this point in the history
* Use subfieldValues: false for toMarcRecord
* Fix tests
* More tests
* Update marc-record:v8.0.0
  • Loading branch information
ammsalme authored Oct 27, 2023
1 parent 48c1a92 commit acaa6b3
Show file tree
Hide file tree
Showing 18 changed files with 354 additions and 32 deletions.
60 changes: 42 additions & 18 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"url": "[email protected]:natlibfi/melinda-rest-api-commons.git"
},
"license": "AGPL-3.0+",
"version": "4.0.16-alpha.8",
"version": "4.0.17-alpha.3",
"main": "./dist/index.js",
"engines": {
"node": ">=18"
Expand All @@ -38,7 +38,7 @@
"build": "babel src --source-maps --copy-files --delete-dir-on-start --out-dir=dist"
},
"dependencies": {
"@natlibfi/marc-record": "^7.3.1",
"@natlibfi/marc-record": "^8.0.0",
"@natlibfi/marc-record-serializers": "^10.1.1",
"@natlibfi/marc-record-validate": "^8.0.1",
"@natlibfi/marc-record-validators-melinda": "^10.13.0",
Expand Down
4 changes: 2 additions & 2 deletions src/amqp.js
Original file line number Diff line number Diff line change
Expand Up @@ -276,8 +276,8 @@ export default async function (AMQP_URL, runHealthCheck = false) {

return messages.map(message => {
const content = JSON.parse(message.content.toString());
// Should we have here validationOptions
return new MarcRecord(content.data);
// Use subfieldValues: false validationOption here
return new MarcRecord(content.data, {subfieldValues: false});
});
}

Expand Down
2 changes: 1 addition & 1 deletion test-fixtures/amqp/03/expectedMessage.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
},
"records": [
{
"_validationOptions": {},
"_validationOptions": {"subfieldValues": false},
"fields": [
{
"tag": "001",
Expand Down
2 changes: 1 addition & 1 deletion test-fixtures/amqp/04/expectedMessage.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
},
"records": [
{
"_validationOptions": {},
"_validationOptions": {"subfieldValues": false},
"fields": [
{
"tag": "001",
Expand Down
2 changes: 1 addition & 1 deletion test-fixtures/amqp/05/expectedMessage.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
},
"records": [
{
"_validationOptions": {},
"_validationOptions": {"subfieldValues": false},
"fields": [
{
"tag": "001",
Expand Down
2 changes: 1 addition & 1 deletion test-fixtures/amqp/06/expectedMessage.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
},
"records": [
{
"_validationOptions": {},
"_validationOptions": {"subfieldValues": false},
"fields": [
{
"tag": "001",
Expand Down
6 changes: 3 additions & 3 deletions test-fixtures/amqp/08/expectedResult.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[
{
"_validationOptions": {},
"_validationOptions": {"subfieldValues": false},
"leader": "02518cam a2200745zi 4500",
"fields": [
{
Expand All @@ -10,7 +10,7 @@
]
},
{
"_validationOptions": {},
"_validationOptions": {"subfieldValues": false},
"leader": "02518cam a2200745zi 4500",
"fields": [
{
Expand All @@ -20,7 +20,7 @@
]
},
{
"_validationOptions": {},
"_validationOptions": {"subfieldValues": false},
"leader": "02518cam a2200745zi 4500",
"fields": [
{
Expand Down
6 changes: 3 additions & 3 deletions test-fixtures/amqp/09/expectedResult.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[
{
"_validationOptions": {},
"_validationOptions": {"subfieldValues": false},
"leader": "02518cam a2200745zi 4500",
"fields": [
{
Expand All @@ -10,7 +10,7 @@
]
},
{
"_validationOptions": {},
"_validationOptions": {"subfieldValues": false},
"leader": "02518cam a2200745zi 4500",
"fields": [
{
Expand All @@ -20,7 +20,7 @@
]
},
{
"_validationOptions": {},
"_validationOptions": {"subfieldValues": false},
"leader": "02518cam a2200745zi 4500",
"fields": [
{
Expand Down
59 changes: 59 additions & 0 deletions test-fixtures/amqp/20/expectedResult.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
[
{
"_validationOptions": {"subfieldValues": false},
"leader": "02518cam a2200745zi 4500",
"fields": [
{
"tag": "001",
"value": "000019640"
},
{
"tag": "CAT",
"ind1": " ",
"ind2": " ",
"subfields": [
{
"code": "a",
"value": "IMP_HELMET"
},
{
"code": "b",
"value": ""
},
{
"code": "c",
"value": "20220109"
},
{
"code": "l",
"value": "FIN01"
},
{
"code": "h",
"value": "0838"
}
]
}
]
},
{
"_validationOptions": {"subfieldValues": false},
"leader": "02518cam a2200745zi 4500",
"fields": [
{
"tag": "001",
"value": "000019641"
}
]
},
{
"_validationOptions": {"subfieldValues": false},
"leader": "02518cam a2200745zi 4500",
"fields": [
{
"tag": "001",
"value": "000019642"
}
]
}
]
77 changes: 77 additions & 0 deletions test-fixtures/amqp/20/input.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
[
{
"queue": "TESTQUEUE",
"correlationId": "aaaaaaaa-0000-aaaa-0000-000000000000",
"headers": {
"correlationId": "aaaaaaaa-0000-aaaa-0000-000000000000"
},
"data": {
"leader": "02518cam a2200745zi 4500",
"fields": [
{
"tag": "001",
"value": "000019640"
},
{
"tag": "CAT",
"ind1": " ",
"ind2": " ",
"subfields": [
{
"code": "a",
"value": "IMP_HELMET"
},
{
"code": "b",
"value": ""
},
{
"code": "c",
"value": "20220109"
},
{
"code": "l",
"value": "FIN01"
},
{
"code": "h",
"value": "0838"
}
]
}
]
}
},
{
"queue": "TESTQUEUE",
"correlationId": "aaaaaaaa-0000-aaaa-0000-000000000000",
"headers": {
"correlationId": "aaaaaaaa-0000-aaaa-0000-000000000000"
},
"data": {
"leader": "02518cam a2200745zi 4500",
"fields": [
{
"tag": "001",
"value": "000019641"
}
]
}
},
{
"queue": "TESTQUEUE",
"correlationId": "aaaaaaaa-0000-aaaa-0000-000000000000",
"headers": {
"correlationId": "aaaaaaaa-0000-aaaa-0000-000000000000"
},
"data": {
"leader": "02518cam a2200745zi 4500",
"fields": [
{
"tag": "001",
"value": "000019642"
}
]
}
}
]
8 changes: 8 additions & 0 deletions test-fixtures/amqp/20/metadata.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"description": "CheckQueue - accept records with empty subfield values: basic, toRecord",
"skip": false,
"only": false,
"expectedMessageCount": 0,
"sentToQueue": true,
"checkQueueStyle": "basicToRecord"
}
Loading

0 comments on commit acaa6b3

Please sign in to comment.