@natlibfi/oracledb-mock 1.0.3 → 2.0.0-alpha.3
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-and-publish.yml +105 -0
- package/README.md +1 -1
- package/dist/index.js +20 -65
- package/dist/index.js.map +7 -1
- package/dist/index.test.js +48 -0
- package/dist/index.test.js.map +7 -0
- package/eslint.config.js +52 -0
- package/package.json +14 -83
- package/src/index.js +10 -10
- package/src/{index.spec.js → index.test.js} +7 -6
- package/.drone.yml +0 -92
- package/.github/workflows/node-tests.yml +0 -70
- package/dist/index.spec.js +0 -92
- package/dist/index.spec.js.map +0 -1
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
# Melinda node tests and publish
|
|
2
|
+
|
|
3
|
+
name: Melinda-node-tests-and-publish
|
|
4
|
+
|
|
5
|
+
on: push
|
|
6
|
+
|
|
7
|
+
permissions: # Required for trusted publishing https://docs.npmjs.com/trusted-publishers
|
|
8
|
+
id-token: write
|
|
9
|
+
contents: read
|
|
10
|
+
|
|
11
|
+
jobs:
|
|
12
|
+
|
|
13
|
+
### TESTS
|
|
14
|
+
|
|
15
|
+
build-node-versions:
|
|
16
|
+
name: Node version matrix
|
|
17
|
+
runs-on: ubuntu-latest
|
|
18
|
+
|
|
19
|
+
strategy:
|
|
20
|
+
matrix:
|
|
21
|
+
node-version: [22.x, 24.x]
|
|
22
|
+
# See supported Node.js release schedule at https://nodejs.org/en/about/releases/
|
|
23
|
+
|
|
24
|
+
steps:
|
|
25
|
+
- name: Checkout the code
|
|
26
|
+
uses: actions/checkout@v5
|
|
27
|
+
- name: Use Node.js ${{ matrix.node-version }}
|
|
28
|
+
uses: actions/setup-node@v6
|
|
29
|
+
with:
|
|
30
|
+
node-version: ${{ matrix.node-version }}
|
|
31
|
+
cache: 'npm'
|
|
32
|
+
env:
|
|
33
|
+
NPM_CONFIG_IGNORE_SCRIPTS: true
|
|
34
|
+
- run: npm audit --package-lock-only --production --audit-level=moderate
|
|
35
|
+
- run: npm i
|
|
36
|
+
- run: npm test
|
|
37
|
+
- run: npm run build --if-present
|
|
38
|
+
|
|
39
|
+
njsscan:
|
|
40
|
+
name: Njsscan-check
|
|
41
|
+
runs-on: ubuntu-latest
|
|
42
|
+
|
|
43
|
+
steps:
|
|
44
|
+
- name: Checkout the code
|
|
45
|
+
uses: actions/checkout@v5
|
|
46
|
+
- name: nodejsscan scan
|
|
47
|
+
id: njsscan
|
|
48
|
+
uses: ajinabraham/njsscan-action@master
|
|
49
|
+
with:
|
|
50
|
+
args: '.'
|
|
51
|
+
|
|
52
|
+
license-scan:
|
|
53
|
+
name: License compliance check
|
|
54
|
+
runs-on: ubuntu-latest
|
|
55
|
+
|
|
56
|
+
steps:
|
|
57
|
+
- uses: actions/checkout@v5
|
|
58
|
+
- uses: mikaelvesavuori/license-compliance-action@v1.0.2
|
|
59
|
+
with:
|
|
60
|
+
exclude_pattern: /^@natlibfi/
|
|
61
|
+
|
|
62
|
+
# publish:
|
|
63
|
+
# runs-on: ubuntu-latest
|
|
64
|
+
# needs: [build-node-versions, njsscan]
|
|
65
|
+
# if: contains(github.ref, 'refs/tags/')
|
|
66
|
+
|
|
67
|
+
# steps:
|
|
68
|
+
# - uses: actions/checkout@v5
|
|
69
|
+
# # Setup .npmrc file to publish to npm
|
|
70
|
+
# - uses: actions/setup-node@v6
|
|
71
|
+
# with:
|
|
72
|
+
# node-version: '22.x'
|
|
73
|
+
# registry-url: 'https://registry.npmjs.org'
|
|
74
|
+
# - run: npm i
|
|
75
|
+
# - run: npm publish
|
|
76
|
+
# env:
|
|
77
|
+
# NODE_AUTH_TOKEN: ${{ secrets.ORACLEDB_MOCK_NPM_TOKEN }}
|
|
78
|
+
|
|
79
|
+
## PUBLISH
|
|
80
|
+
|
|
81
|
+
publish:
|
|
82
|
+
runs-on: ubuntu-latest
|
|
83
|
+
needs: [build-node-versions, njsscan]
|
|
84
|
+
if: contains(github.ref, 'refs/tags/')
|
|
85
|
+
|
|
86
|
+
steps:
|
|
87
|
+
- uses: actions/checkout@v5
|
|
88
|
+
# Setup .npmrc file to publish to npm
|
|
89
|
+
- uses: actions/setup-node@v6
|
|
90
|
+
with:
|
|
91
|
+
node-version: '22.x'
|
|
92
|
+
registry-url: 'https://registry.npmjs.org'
|
|
93
|
+
- name: Update npm
|
|
94
|
+
run: npm install -g npm@latest
|
|
95
|
+
- name: Clean install
|
|
96
|
+
run: npm ci
|
|
97
|
+
# Add build step here if you don't have prepare script
|
|
98
|
+
# Publish stable release with --tag=latest
|
|
99
|
+
- name: Publish stable release
|
|
100
|
+
if: ${{!contains(github.ref, '-alpha')}}
|
|
101
|
+
run: npm publish --tag=latest
|
|
102
|
+
# Publish pre-release without --tag latest
|
|
103
|
+
- name: Publish pre-release
|
|
104
|
+
if: contains(github.ref, '-alpha')
|
|
105
|
+
run: npm publish --tag=next
|
package/README.md
CHANGED
|
@@ -35,6 +35,6 @@ The `_execute` method initializes the mock with expected queries and their resul
|
|
|
35
35
|
|
|
36
36
|
## License and copyright
|
|
37
37
|
|
|
38
|
-
Copyright (c) 2020 **University Of Helsinki (The National Library Of Finland)**
|
|
38
|
+
Copyright (c) 2020, 2025 **University Of Helsinki (The National Library Of Finland)**
|
|
39
39
|
|
|
40
40
|
This project's source code is licensed under the terms of **GNU Lesser General Public License Version 3** or any later version.
|
package/dist/index.js
CHANGED
|
@@ -1,72 +1,33 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.default = void 0;
|
|
7
|
-
var _deepEql = _interopRequireDefault(require("deep-eql"));
|
|
8
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
9
|
-
/**
|
|
10
|
-
*
|
|
11
|
-
* @licstart The following is the entire license notice for the JavaScript code in this file.
|
|
12
|
-
*
|
|
13
|
-
* A mock for oracledb Node.js module
|
|
14
|
-
*
|
|
15
|
-
* Copyright (C) 2020 University Of Helsinki (The National Library Of Finland)
|
|
16
|
-
*
|
|
17
|
-
* This file is part of oracledb-mock-js
|
|
18
|
-
*
|
|
19
|
-
* oracledb-mock-js program is free software: you can redistribute it and/or modify
|
|
20
|
-
* it under the terms of the GNU Affero General Public License as
|
|
21
|
-
* published by the Free Software Foundation, either version 3 of the
|
|
22
|
-
* License, or (at your option) any later version.
|
|
23
|
-
*
|
|
24
|
-
* oracledb-mock-js is distributed in the hope that it will be useful,
|
|
25
|
-
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
26
|
-
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
27
|
-
* GNU Affero General Public License for more details.
|
|
28
|
-
*
|
|
29
|
-
* You should have received a copy of the GNU Affero General Public License
|
|
30
|
-
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
31
|
-
*
|
|
32
|
-
* @licend The above is the entire license notice
|
|
33
|
-
* for the JavaScript code in this file.
|
|
34
|
-
*
|
|
35
|
-
*/
|
|
36
|
-
var _default = () => {
|
|
1
|
+
import deepEqual from "deep-eql";
|
|
2
|
+
export default () => {
|
|
37
3
|
const options = [];
|
|
38
4
|
const DEFAULT_OPTIONS = {
|
|
39
5
|
queryPattern: /.*/u,
|
|
40
6
|
results: []
|
|
41
7
|
};
|
|
42
8
|
const connection = {
|
|
43
|
-
close: () => {
|
|
44
|
-
|
|
45
|
-
break: () => {
|
|
46
|
-
|
|
9
|
+
close: () => {
|
|
10
|
+
},
|
|
11
|
+
break: () => {
|
|
12
|
+
},
|
|
47
13
|
execute: (query, args) => {
|
|
48
14
|
const rows = getRows();
|
|
49
15
|
return {
|
|
50
16
|
resultSet: {
|
|
51
17
|
getRow: () => rows.shift(),
|
|
52
|
-
|
|
53
|
-
|
|
18
|
+
close: () => {
|
|
19
|
+
}
|
|
54
20
|
}
|
|
55
21
|
};
|
|
56
22
|
function getRows() {
|
|
57
|
-
const index = options.findIndex(({
|
|
58
|
-
queryPattern,
|
|
59
|
-
expectedArgs
|
|
60
|
-
}) => {
|
|
61
|
-
if (queryPattern.test(query) && (expectedArgs === undefined || (0, _deepEql.default)(args, expectedArgs))) {
|
|
23
|
+
const index = options.findIndex(({ queryPattern, expectedArgs }) => {
|
|
24
|
+
if (queryPattern.test(query) && (expectedArgs === void 0 || deepEqual(args, expectedArgs))) {
|
|
62
25
|
return true;
|
|
63
26
|
}
|
|
64
27
|
return false;
|
|
65
28
|
});
|
|
66
29
|
if (index >= 0) {
|
|
67
|
-
const {
|
|
68
|
-
results
|
|
69
|
-
} = options.splice(index, 1).shift(); // eslint-disable-line functional/immutable-data
|
|
30
|
+
const { results } = options.splice(index, 1).shift();
|
|
70
31
|
return results;
|
|
71
32
|
}
|
|
72
33
|
return [];
|
|
@@ -77,25 +38,19 @@ var _default = () => {
|
|
|
77
38
|
getConnection: () => connection,
|
|
78
39
|
createPool: () => ({
|
|
79
40
|
getConnection: () => connection,
|
|
80
|
-
close: () => {
|
|
41
|
+
close: () => {
|
|
42
|
+
}
|
|
81
43
|
}),
|
|
82
44
|
_clear: () => {
|
|
83
|
-
|
|
84
|
-
options.
|
|
85
|
-
Object.keys(options).forEach(k => delete options[k]); // eslint-disable-line functional/immutable-data
|
|
45
|
+
options.splice(0);
|
|
46
|
+
Object.keys(options).forEach((k) => delete options[k]);
|
|
86
47
|
},
|
|
87
|
-
_execute: optList => {
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
optList.forEach(opts => {
|
|
92
|
-
options.push({
|
|
93
|
-
...DEFAULT_OPTIONS,
|
|
94
|
-
...opts
|
|
95
|
-
}); // eslint-disable-line functional/immutable-data
|
|
48
|
+
_execute: (optList) => {
|
|
49
|
+
options.splice(0);
|
|
50
|
+
optList.forEach((opts) => {
|
|
51
|
+
options.push({ ...DEFAULT_OPTIONS, ...opts });
|
|
96
52
|
});
|
|
97
53
|
}
|
|
98
54
|
};
|
|
99
55
|
};
|
|
100
|
-
|
|
101
|
-
//# sourceMappingURL=index.js.map
|
|
56
|
+
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1,7 @@
|
|
|
1
|
-
{
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/index.js"],
|
|
4
|
+
"sourcesContent": ["/**\n*\n* @licstart The following is the entire license notice for the JavaScript code in this file.\n*\n* A mock for oracledb Node.js module\n*\n* Copyright (C) 2020 University Of Helsinki (The National Library Of Finland)\n*\n* This file is part of oracledb-mock-js\n*\n* oracledb-mock-js program is free software: you can redistribute it and/or modify\n* it under the terms of the GNU Affero General Public License as\n* published by the Free Software Foundation, either version 3 of the\n* License, or (at your option) any later version.\n*\n* oracledb-mock-js is distributed in the hope that it will be useful,\n* but WITHOUT ANY WARRANTY; without even the implied warranty of\n* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n* GNU Affero General Public License for more details.\n*\n* You should have received a copy of the GNU Affero General Public License\n* along with this program. If not, see <http://www.gnu.org/licenses/>.\n*\n* @licend The above is the entire license notice\n* for the JavaScript code in this file.\n*\n*/\n\nimport deepEqual from 'deep-eql';\n\nexport default () => {\n const options = [];\n const DEFAULT_OPTIONS = {\n queryPattern: /.*/u,\n results: []\n };\n\n const connection = {\n close: () => {},\n break: () => {},\n execute: (query, args) => {\n const rows = getRows();\n\n return {\n resultSet: {\n getRow: () => rows.shift(),\n close: () => {}\n }\n };\n\n function getRows() {\n const index = options.findIndex(({queryPattern, expectedArgs}) => {\n if (queryPattern.test(query) && (expectedArgs === undefined || deepEqual(args, expectedArgs))) {\n return true;\n }\n\n return false;\n });\n\n if (index >= 0) {\n const {results} = options.splice(index, 1).shift();\n return results;\n }\n\n return [];\n }\n }\n };\n\n return {\n getConnection: () => connection,\n createPool: () => ({\n getConnection: () => connection,\n close: () => {}\n }),\n _clear: () => {\n // Clear array\n options.splice(0);\n Object.keys(options).forEach(k => delete options[k]);\n },\n _execute: optList => {\n // Clear array\n options.splice(0);\n\n optList.forEach(opts => {\n options.push({...DEFAULT_OPTIONS, ...opts});\n });\n }\n };\n};\n"],
|
|
5
|
+
"mappings": "AA4BA,OAAO,eAAe;AAEtB,eAAe,MAAM;AACnB,QAAM,UAAU,CAAC;AACjB,QAAM,kBAAkB;AAAA,IACtB,cAAc;AAAA,IACd,SAAS,CAAC;AAAA,EACZ;AAEA,QAAM,aAAa;AAAA,IACjB,OAAO,MAAM;AAAA,IAAC;AAAA,IACd,OAAO,MAAM;AAAA,IAAC;AAAA,IACd,SAAS,CAAC,OAAO,SAAS;AACxB,YAAM,OAAO,QAAQ;AAErB,aAAO;AAAA,QACL,WAAW;AAAA,UACT,QAAQ,MAAM,KAAK,MAAM;AAAA,UACzB,OAAO,MAAM;AAAA,UAAC;AAAA,QAChB;AAAA,MACF;AAEA,eAAS,UAAU;AACjB,cAAM,QAAQ,QAAQ,UAAU,CAAC,EAAC,cAAc,aAAY,MAAM;AAChE,cAAI,aAAa,KAAK,KAAK,MAAM,iBAAiB,UAAa,UAAU,MAAM,YAAY,IAAI;AAC7F,mBAAO;AAAA,UACT;AAEA,iBAAO;AAAA,QACT,CAAC;AAED,YAAI,SAAS,GAAG;AACd,gBAAM,EAAC,QAAO,IAAI,QAAQ,OAAO,OAAO,CAAC,EAAE,MAAM;AACjD,iBAAO;AAAA,QACT;AAEA,eAAO,CAAC;AAAA,MACV;AAAA,IACF;AAAA,EACF;AAEA,SAAO;AAAA,IACL,eAAe,MAAM;AAAA,IACrB,YAAY,OAAO;AAAA,MACjB,eAAe,MAAM;AAAA,MACrB,OAAO,MAAM;AAAA,MAAC;AAAA,IAChB;AAAA,IACA,QAAQ,MAAM;AAEZ,cAAQ,OAAO,CAAC;AAChB,aAAO,KAAK,OAAO,EAAE,QAAQ,OAAK,OAAO,QAAQ,CAAC,CAAC;AAAA,IACrD;AAAA,IACA,UAAU,aAAW;AAEnB,cAAQ,OAAO,CAAC;AAEhB,cAAQ,QAAQ,UAAQ;AACtB,gBAAQ,KAAK,EAAC,GAAG,iBAAiB,GAAG,KAAI,CAAC;AAAA,MAC5C,CAAC;AAAA,IACH;AAAA,EACF;AACF;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import createMock from "./index.js";
|
|
2
|
+
import generateTests from "@natlibfi/fixugen";
|
|
3
|
+
import assert from "node:assert";
|
|
4
|
+
generateTests({
|
|
5
|
+
useMetadataFile: true,
|
|
6
|
+
path: [import.meta.dirname, "..", "test-fixtures"],
|
|
7
|
+
callback: async ({ dbResults, usePool = false, expectedResults, query, args = {} }) => {
|
|
8
|
+
const mock = createMock();
|
|
9
|
+
mock._execute(formatDbResults());
|
|
10
|
+
if (usePool) {
|
|
11
|
+
const pool = await mock.createPool();
|
|
12
|
+
const connection2 = await pool.getConnection();
|
|
13
|
+
const { resultSet: resultSet2 } = await connection2.execute(query, args);
|
|
14
|
+
const results2 = await fetchResults(resultSet2);
|
|
15
|
+
assert.deepEqual(results2, expectedResults);
|
|
16
|
+
await connection2.close();
|
|
17
|
+
await pool.close();
|
|
18
|
+
mock._clear();
|
|
19
|
+
return;
|
|
20
|
+
}
|
|
21
|
+
const connection = await mock.getConnection();
|
|
22
|
+
const { resultSet } = await connection.execute(query, args);
|
|
23
|
+
const results = await fetchResults(resultSet);
|
|
24
|
+
assert.deepEqual(results, expectedResults);
|
|
25
|
+
await connection.close();
|
|
26
|
+
mock._clear();
|
|
27
|
+
async function fetchResults(resultSet2, results2 = []) {
|
|
28
|
+
const row = await resultSet2.getRow();
|
|
29
|
+
if (row) {
|
|
30
|
+
return fetchResults(resultSet2, results2.concat(row));
|
|
31
|
+
}
|
|
32
|
+
await resultSet2.close();
|
|
33
|
+
return results2;
|
|
34
|
+
}
|
|
35
|
+
function formatDbResults() {
|
|
36
|
+
return dbResults.map(({ queryPattern, ...rest }) => {
|
|
37
|
+
if (queryPattern) {
|
|
38
|
+
return {
|
|
39
|
+
...rest,
|
|
40
|
+
queryPattern: new RegExp(queryPattern, "u")
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
return rest;
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
});
|
|
48
|
+
//# sourceMappingURL=index.test.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/index.test.js"],
|
|
4
|
+
"sourcesContent": ["/**\n*\n* @licstart The following is the entire license notice for the JavaScript code in this file.\n*\n* A mock for oracledb Node.js module\n*\n* Copyright (C) 2020 University Of Helsinki (The National Library Of Finland)\n*\n* This file is part of oracledb-mock-js\n*\n* oracledb-mock-js program is free software: you can redistribute it and/or modify\n* it under the terms of the GNU Affero General Public License as\n* published by the Free Software Foundation, either version 3 of the\n* License, or (at your option) any later version.\n*\n* oracledb-mock-js is distributed in the hope that it will be useful,\n* but WITHOUT ANY WARRANTY; without even the implied warranty of\n* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n* GNU Affero General Public License for more details.\n*\n* You should have received a copy of the GNU Affero General Public License\n* along with this program. If not, see <http://www.gnu.org/licenses/>.\n*\n* @licend The above is the entire license notice\n* for the JavaScript code in this file.\n*\n*/\n\nimport createMock from './index.js';\nimport generateTests from '@natlibfi/fixugen';\nimport assert from 'node:assert';\n\ngenerateTests({\n useMetadataFile: true,\n path: [import.meta.dirname, '..', 'test-fixtures'],\n callback: async ({dbResults, usePool = false, expectedResults, query, args = {}}) => {\n const mock = createMock();\n\n mock._execute(formatDbResults());\n\n if (usePool) {\n const pool = await mock.createPool();\n const connection = await pool.getConnection();\n const {resultSet} = await connection.execute(query, args);\n const results = await fetchResults(resultSet);\n\n //expect(results).to.eql(expectedResults);\n assert.deepEqual(results, expectedResults);\n\n await connection.close();\n await pool.close();\n\n mock._clear();\n return;\n }\n\n const connection = await mock.getConnection();\n const {resultSet} = await connection.execute(query, args);\n const results = await fetchResults(resultSet);\n\n // expect(results).to.eql(expectedResults);\n assert.deepEqual(results, expectedResults);\n await connection.close();\n mock._clear();\n\n async function fetchResults(resultSet, results = []) {\n const row = await resultSet.getRow();\n\n if (row) {\n return fetchResults(resultSet, results.concat(row));\n }\n\n await resultSet.close();\n return results;\n }\n\n function formatDbResults() {\n return dbResults.map(({queryPattern, ...rest}) => {\n if (queryPattern) {\n return {\n ...rest,\n queryPattern: new RegExp(queryPattern, 'u')\n };\n }\n\n return rest;\n });\n }\n }\n});\n"],
|
|
5
|
+
"mappings": "AA4BA,OAAO,gBAAgB;AACvB,OAAO,mBAAmB;AAC1B,OAAO,YAAY;AAEnB,cAAc;AAAA,EACZ,iBAAiB;AAAA,EACjB,MAAM,CAAC,YAAY,SAAS,MAAM,eAAe;AAAA,EACjD,UAAU,OAAO,EAAC,WAAW,UAAU,OAAO,iBAAiB,OAAO,OAAO,CAAC,EAAC,MAAM;AACnF,UAAM,OAAO,WAAW;AAExB,SAAK,SAAS,gBAAgB,CAAC;AAE/B,QAAI,SAAS;AACX,YAAM,OAAO,MAAM,KAAK,WAAW;AACnC,YAAMA,cAAa,MAAM,KAAK,cAAc;AAC5C,YAAM,EAAC,WAAAC,WAAS,IAAI,MAAMD,YAAW,QAAQ,OAAO,IAAI;AACxD,YAAME,WAAU,MAAM,aAAaD,UAAS;AAG5C,aAAO,UAAUC,UAAS,eAAe;AAEzC,YAAMF,YAAW,MAAM;AACvB,YAAM,KAAK,MAAM;AAEjB,WAAK,OAAO;AACZ;AAAA,IACF;AAEA,UAAM,aAAa,MAAM,KAAK,cAAc;AAC5C,UAAM,EAAC,UAAS,IAAI,MAAM,WAAW,QAAQ,OAAO,IAAI;AACxD,UAAM,UAAU,MAAM,aAAa,SAAS;AAG5C,WAAO,UAAU,SAAS,eAAe;AACzC,UAAM,WAAW,MAAM;AACvB,SAAK,OAAO;AAEZ,mBAAe,aAAaC,YAAWC,WAAU,CAAC,GAAG;AACnD,YAAM,MAAM,MAAMD,WAAU,OAAO;AAEnC,UAAI,KAAK;AACP,eAAO,aAAaA,YAAWC,SAAQ,OAAO,GAAG,CAAC;AAAA,MACpD;AAEA,YAAMD,WAAU,MAAM;AACtB,aAAOC;AAAA,IACT;AAEA,aAAS,kBAAkB;AACzB,aAAO,UAAU,IAAI,CAAC,EAAC,cAAc,GAAG,KAAI,MAAM;AAChD,YAAI,cAAc;AAChB,iBAAO;AAAA,YACL,GAAG;AAAA,YACH,cAAc,IAAI,OAAO,cAAc,GAAG;AAAA,UAC5C;AAAA,QACF;AAEA,eAAO;AAAA,MACT,CAAC;AAAA,IACH;AAAA,EACF;AACF,CAAC;",
|
|
6
|
+
"names": ["connection", "resultSet", "results"]
|
|
7
|
+
}
|
package/eslint.config.js
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
// Eslint configuration object for src
|
|
2
|
+
const configSrc = {
|
|
3
|
+
files: [
|
|
4
|
+
"src/*"
|
|
5
|
+
],
|
|
6
|
+
linterOptions: {
|
|
7
|
+
reportUnusedDisableDirectives: true,
|
|
8
|
+
},
|
|
9
|
+
rules: {
|
|
10
|
+
"no-console": "warn",
|
|
11
|
+
"eqeqeq": ["error", "always"],
|
|
12
|
+
"no-const-assign": "error",
|
|
13
|
+
"max-depth": ["warn", 4],
|
|
14
|
+
"max-lines": ["warn", 500],
|
|
15
|
+
"max-lines-per-function": ["warn", {"max": 100}],
|
|
16
|
+
"no-else-return": ["error", {allowElseIf: false}],
|
|
17
|
+
"no-plusplus": [
|
|
18
|
+
"error",
|
|
19
|
+
{
|
|
20
|
+
"allowForLoopAfterthoughts": true
|
|
21
|
+
}
|
|
22
|
+
],
|
|
23
|
+
"array-callback-return": [
|
|
24
|
+
"error",
|
|
25
|
+
{
|
|
26
|
+
"checkForEach": false
|
|
27
|
+
}
|
|
28
|
+
],
|
|
29
|
+
"no-unused-vars": [
|
|
30
|
+
"error",
|
|
31
|
+
{
|
|
32
|
+
"argsIgnorePattern": "next"
|
|
33
|
+
}
|
|
34
|
+
],
|
|
35
|
+
"no-warning-comments": "off"
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
// Eslint configuration object for globally ignoring .js files
|
|
40
|
+
// - ignore all files that start with a dot
|
|
41
|
+
// - ignore all files inside directories named 'dist'
|
|
42
|
+
const configIgnores = {
|
|
43
|
+
ignores: [
|
|
44
|
+
"**/.*",
|
|
45
|
+
"**/dist/"
|
|
46
|
+
]
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
export default [
|
|
50
|
+
configSrc,
|
|
51
|
+
configIgnores
|
|
52
|
+
];
|
package/package.json
CHANGED
|
@@ -5,109 +5,40 @@
|
|
|
5
5
|
"name": "The National Library of Finland"
|
|
6
6
|
},
|
|
7
7
|
"keywords": [],
|
|
8
|
-
"homepage": "https://
|
|
8
|
+
"homepage": "https://www.npmjs.com/package/@natlibfi/oracledb-moc",
|
|
9
9
|
"bugs": {
|
|
10
10
|
"url": "https://github.com/natlibfi/oracledb-mock-js/issues"
|
|
11
11
|
},
|
|
12
12
|
"repository": {
|
|
13
|
-
"
|
|
14
|
-
"url": "git@github.com:natlibfi/oracledb-mock-js.git"
|
|
13
|
+
"url": "https://github.com/NatLibFi/oracledb-mock-js"
|
|
15
14
|
},
|
|
16
15
|
"license": "LGPL-3.0+",
|
|
17
|
-
"version": "
|
|
16
|
+
"version": "2.0.0-alpha.3",
|
|
17
|
+
"type": "module",
|
|
18
18
|
"main": "./dist/index.js",
|
|
19
19
|
"engines": {
|
|
20
|
-
"node": ">=
|
|
20
|
+
"node": ">=22"
|
|
21
21
|
},
|
|
22
22
|
"publishConfig": {
|
|
23
23
|
"access": "public"
|
|
24
24
|
},
|
|
25
25
|
"scripts": {
|
|
26
26
|
"prepare": "npm run build",
|
|
27
|
-
"build": "
|
|
27
|
+
"build": "esbuild \"src/**/*.js\" --sourcemap --platform=node --outdir=dist",
|
|
28
28
|
"lint": "eslint ./src",
|
|
29
29
|
"lint:dev": "eslint --fix ./src",
|
|
30
30
|
"test": "npm run lint && npm run test:base",
|
|
31
|
-
"test:base": "
|
|
32
|
-
"test
|
|
33
|
-
"coverage": "nyc check-coverage --per-file",
|
|
34
|
-
"dev": "nodemon",
|
|
35
|
-
"dev:debug": "cross-env LOG_LEVEL=debug DEBUG=@natlibfi/* NODE_ENV=test nodemon",
|
|
36
|
-
"watch:test": "cross-env DEBUG=@natlibfi/* NODE_ENV=test nodemon -w src -w test-fixtures --exec 'npm run test:dev'"
|
|
31
|
+
"test:base": "node --test --test-force-exit --experimental-test-coverage --test-reporter=spec './src/**/*.test.js'",
|
|
32
|
+
"dev:test": "cross-env DEBUG=@natlibfi/* NODE_ENV=test node --watch --test --experimental-test-coverage --test-reporter=spec './src/**/*.test.js'"
|
|
37
33
|
},
|
|
38
34
|
"dependencies": {
|
|
39
|
-
"deep-eql": "^4.1.
|
|
35
|
+
"deep-eql": "^4.1.4"
|
|
40
36
|
},
|
|
41
37
|
"devDependencies": {
|
|
42
|
-
"@
|
|
43
|
-
"@
|
|
44
|
-
"
|
|
45
|
-
"
|
|
46
|
-
"
|
|
47
|
-
"@natlibfi/eslint-config-melinda-backend": "^3.0.3",
|
|
48
|
-
"@natlibfi/fixugen": "^2.0.3",
|
|
49
|
-
"@natlibfi/fixura": "^3.0.3",
|
|
50
|
-
"babel-plugin-istanbul": "^6.1.1",
|
|
51
|
-
"chai": "^4.3.10",
|
|
52
|
-
"cross-env": "^7.0.3",
|
|
53
|
-
"eslint": "^8.56.0",
|
|
54
|
-
"mocha": "^10.2.0",
|
|
55
|
-
"nodemon": "^3.0.2",
|
|
56
|
-
"nyc": "^15.1.0"
|
|
57
|
-
},
|
|
58
|
-
"eslintConfig": {
|
|
59
|
-
"extends": "@natlibfi/melinda-backend"
|
|
60
|
-
},
|
|
61
|
-
"babel": {
|
|
62
|
-
"presets": [
|
|
63
|
-
[
|
|
64
|
-
"@babel/preset-env",
|
|
65
|
-
{
|
|
66
|
-
"targets": "maintained node versions"
|
|
67
|
-
}
|
|
68
|
-
]
|
|
69
|
-
],
|
|
70
|
-
"env": {
|
|
71
|
-
"test": {
|
|
72
|
-
"plugins": [
|
|
73
|
-
"istanbul"
|
|
74
|
-
]
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
},
|
|
78
|
-
"mocha": {
|
|
79
|
-
"spec": [
|
|
80
|
-
"src/*.spec.js",
|
|
81
|
-
"src/**/*.spec.js"
|
|
82
|
-
],
|
|
83
|
-
"require": [
|
|
84
|
-
"@babel/register"
|
|
85
|
-
],
|
|
86
|
-
"inline-diffs": true,
|
|
87
|
-
"maxDiffSize": 25000,
|
|
88
|
-
"bail": true,
|
|
89
|
-
"exit": true
|
|
90
|
-
},
|
|
91
|
-
"nodemonConfig": {
|
|
92
|
-
"exec": "npm run test:dev",
|
|
93
|
-
"watch": [
|
|
94
|
-
"src/*",
|
|
95
|
-
"test-fixtures/*"
|
|
96
|
-
]
|
|
97
|
-
},
|
|
98
|
-
"nyc": {
|
|
99
|
-
"exclude": [
|
|
100
|
-
"src/*.spec.js",
|
|
101
|
-
"src/**/*.spec.js"
|
|
102
|
-
],
|
|
103
|
-
"reporter": [
|
|
104
|
-
"text"
|
|
105
|
-
],
|
|
106
|
-
"sourceMap": false,
|
|
107
|
-
"instrument": false,
|
|
108
|
-
"lines": 80,
|
|
109
|
-
"statements": 80,
|
|
110
|
-
"functions": 80,
|
|
111
|
-
"branches": 80
|
|
38
|
+
"@natlibfi/fixugen": "^3.0.0",
|
|
39
|
+
"@natlibfi/fixura": "^4.0.0",
|
|
40
|
+
"cross-env": "^10.1.0",
|
|
41
|
+
"esbuild": "^0.25.12",
|
|
42
|
+
"eslint": "^9.39.1"
|
|
112
43
|
}
|
|
113
44
|
}
|
package/src/index.js
CHANGED
|
@@ -36,15 +36,15 @@ export default () => {
|
|
|
36
36
|
};
|
|
37
37
|
|
|
38
38
|
const connection = {
|
|
39
|
-
close: () => {},
|
|
40
|
-
break: () => {},
|
|
39
|
+
close: () => {},
|
|
40
|
+
break: () => {},
|
|
41
41
|
execute: (query, args) => {
|
|
42
42
|
const rows = getRows();
|
|
43
43
|
|
|
44
44
|
return {
|
|
45
45
|
resultSet: {
|
|
46
|
-
getRow: () => rows.shift(),
|
|
47
|
-
close: () => {}
|
|
46
|
+
getRow: () => rows.shift(),
|
|
47
|
+
close: () => {}
|
|
48
48
|
}
|
|
49
49
|
};
|
|
50
50
|
|
|
@@ -58,7 +58,7 @@ export default () => {
|
|
|
58
58
|
});
|
|
59
59
|
|
|
60
60
|
if (index >= 0) {
|
|
61
|
-
const {results} = options.splice(index, 1).shift();
|
|
61
|
+
const {results} = options.splice(index, 1).shift();
|
|
62
62
|
return results;
|
|
63
63
|
}
|
|
64
64
|
|
|
@@ -71,19 +71,19 @@ export default () => {
|
|
|
71
71
|
getConnection: () => connection,
|
|
72
72
|
createPool: () => ({
|
|
73
73
|
getConnection: () => connection,
|
|
74
|
-
close: () => {}
|
|
74
|
+
close: () => {}
|
|
75
75
|
}),
|
|
76
76
|
_clear: () => {
|
|
77
77
|
// Clear array
|
|
78
|
-
options.splice(0);
|
|
79
|
-
Object.keys(options).forEach(k => delete options[k]);
|
|
78
|
+
options.splice(0);
|
|
79
|
+
Object.keys(options).forEach(k => delete options[k]);
|
|
80
80
|
},
|
|
81
81
|
_execute: optList => {
|
|
82
82
|
// Clear array
|
|
83
|
-
options.splice(0);
|
|
83
|
+
options.splice(0);
|
|
84
84
|
|
|
85
85
|
optList.forEach(opts => {
|
|
86
|
-
options.push({...DEFAULT_OPTIONS, ...opts});
|
|
86
|
+
options.push({...DEFAULT_OPTIONS, ...opts});
|
|
87
87
|
});
|
|
88
88
|
}
|
|
89
89
|
};
|
|
@@ -26,13 +26,13 @@
|
|
|
26
26
|
*
|
|
27
27
|
*/
|
|
28
28
|
|
|
29
|
-
import createMock from '.';
|
|
29
|
+
import createMock from './index.js';
|
|
30
30
|
import generateTests from '@natlibfi/fixugen';
|
|
31
|
-
import
|
|
31
|
+
import assert from 'node:assert';
|
|
32
32
|
|
|
33
33
|
generateTests({
|
|
34
34
|
useMetadataFile: true,
|
|
35
|
-
path: [
|
|
35
|
+
path: [import.meta.dirname, '..', 'test-fixtures'],
|
|
36
36
|
callback: async ({dbResults, usePool = false, expectedResults, query, args = {}}) => {
|
|
37
37
|
const mock = createMock();
|
|
38
38
|
|
|
@@ -44,7 +44,8 @@ generateTests({
|
|
|
44
44
|
const {resultSet} = await connection.execute(query, args);
|
|
45
45
|
const results = await fetchResults(resultSet);
|
|
46
46
|
|
|
47
|
-
expect(results).to.eql(expectedResults);
|
|
47
|
+
//expect(results).to.eql(expectedResults);
|
|
48
|
+
assert.deepEqual(results, expectedResults);
|
|
48
49
|
|
|
49
50
|
await connection.close();
|
|
50
51
|
await pool.close();
|
|
@@ -57,8 +58,8 @@ generateTests({
|
|
|
57
58
|
const {resultSet} = await connection.execute(query, args);
|
|
58
59
|
const results = await fetchResults(resultSet);
|
|
59
60
|
|
|
60
|
-
|
|
61
|
-
|
|
61
|
+
// expect(results).to.eql(expectedResults);
|
|
62
|
+
assert.deepEqual(results, expectedResults);
|
|
62
63
|
await connection.close();
|
|
63
64
|
mock._clear();
|
|
64
65
|
|
package/.drone.yml
DELETED
|
@@ -1,92 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
kind: pipeline
|
|
3
|
-
type: docker
|
|
4
|
-
name: Default
|
|
5
|
-
|
|
6
|
-
trigger:
|
|
7
|
-
event:
|
|
8
|
-
- push
|
|
9
|
-
- tag
|
|
10
|
-
|
|
11
|
-
steps:
|
|
12
|
-
|
|
13
|
-
- name: audit
|
|
14
|
-
image: node:12
|
|
15
|
-
commands:
|
|
16
|
-
- npm audit --package-lock-only --production --audit-level=moderate
|
|
17
|
-
|
|
18
|
-
- name: install
|
|
19
|
-
image: node:12
|
|
20
|
-
environment:
|
|
21
|
-
NPM_CONFIG_IGNORE_SCRIPTS: true
|
|
22
|
-
commands:
|
|
23
|
-
- npm ci
|
|
24
|
-
|
|
25
|
-
- name: test
|
|
26
|
-
image: node:12
|
|
27
|
-
commands:
|
|
28
|
-
- npm test
|
|
29
|
-
|
|
30
|
-
- name: check-coverage
|
|
31
|
-
image: node:12
|
|
32
|
-
commands:
|
|
33
|
-
- npm run coverage
|
|
34
|
-
|
|
35
|
-
- name: build
|
|
36
|
-
image: node:12
|
|
37
|
-
commands:
|
|
38
|
-
- npm run build
|
|
39
|
-
- npm ci --production
|
|
40
|
-
|
|
41
|
-
- name: static-security-scan
|
|
42
|
-
image: quay.io/natlibfi/nodejsscan
|
|
43
|
-
commands:
|
|
44
|
-
- python /usr/src/app/cli.py -d dist
|
|
45
|
-
|
|
46
|
-
- name: npm
|
|
47
|
-
image: plugins/npm
|
|
48
|
-
settings:
|
|
49
|
-
registry: 'https://registry.npmjs.org/'
|
|
50
|
-
token:
|
|
51
|
-
from_secret: npm_token
|
|
52
|
-
when:
|
|
53
|
-
event: tag
|
|
54
|
-
---
|
|
55
|
-
kind: pipeline
|
|
56
|
-
type: docker
|
|
57
|
-
name: Update dependencies
|
|
58
|
-
|
|
59
|
-
trigger:
|
|
60
|
-
event:
|
|
61
|
-
- custom
|
|
62
|
-
branch:
|
|
63
|
-
- master
|
|
64
|
-
|
|
65
|
-
steps:
|
|
66
|
-
|
|
67
|
-
- name: publish
|
|
68
|
-
image: quay.io/natlibfi/drone-npm-git-publish
|
|
69
|
-
settings:
|
|
70
|
-
git_user_name: natlibfi-melinda-automation
|
|
71
|
-
git_user_email: 65649125+natlibfi-melinda-automation@users.noreply.github.com
|
|
72
|
-
git_ssh_key:
|
|
73
|
-
from_secret: ssh_key
|
|
74
|
-
git_gpg_key:
|
|
75
|
-
from_secret: gpg_key
|
|
76
|
-
---
|
|
77
|
-
kind: secret
|
|
78
|
-
name: npm_token
|
|
79
|
-
data: +LGGkdsxbZ5J49jYZ4cQKB7JaRl1ZL1azpJOMFtml7jVXjXpxohqVvk2Xjz4y6czlEwOISPs/MuB/BKrbWXNqQ==
|
|
80
|
-
---
|
|
81
|
-
kind: secret
|
|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HBNCKAcWSTpZArFWuPGb2T2N9OPxgHKiY/0j99KqklyxP362wxY9fJRwbDCmCsgXDid0HKyN29u6mBEWQ29HeAKYfLiS2hbMLBOIpNjC0F/Rxvhys+li/ybbTef+Rk7KaLpIDqFK+9U1xHRQ5tOks9VN6RP0ZvSw==
|
|
88
|
-
---
|
|
89
|
-
kind: signature
|
|
90
|
-
hmac: 9415ddc069b4a7e2025032ef731a702c377b2c8e2e5bde085a0bb7d0c202aca8
|
|
91
|
-
|
|
92
|
-
...
|
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
# Melinda node tests
|
|
2
|
-
|
|
3
|
-
name: Melinda-node-tests
|
|
4
|
-
|
|
5
|
-
on: push
|
|
6
|
-
|
|
7
|
-
jobs:
|
|
8
|
-
build-node-versions:
|
|
9
|
-
name: Node version matrix
|
|
10
|
-
runs-on: ubuntu-latest
|
|
11
|
-
|
|
12
|
-
strategy:
|
|
13
|
-
matrix:
|
|
14
|
-
node-version: [18.x, 19.x, 20.x]
|
|
15
|
-
# See supported Node.js release schedule at https://nodejs.org/en/about/releases/
|
|
16
|
-
|
|
17
|
-
steps:
|
|
18
|
-
- name: Checkout the code
|
|
19
|
-
uses: actions/checkout@v4
|
|
20
|
-
- name: Use Node.js ${{ matrix.node-version }}
|
|
21
|
-
uses: actions/setup-node@v4
|
|
22
|
-
with:
|
|
23
|
-
node-version: ${{ matrix.node-version }}
|
|
24
|
-
cache: 'npm'
|
|
25
|
-
env:
|
|
26
|
-
NPM_CONFIG_IGNORE_SCRIPTS: true
|
|
27
|
-
- run: npm audit --package-lock-only --production --audit-level=moderate
|
|
28
|
-
- run: npm i
|
|
29
|
-
- run: npm test
|
|
30
|
-
- run: npm run build --if-present
|
|
31
|
-
|
|
32
|
-
njsscan:
|
|
33
|
-
name: Njsscan-check
|
|
34
|
-
runs-on: ubuntu-latest
|
|
35
|
-
|
|
36
|
-
steps:
|
|
37
|
-
- name: Checkout the code
|
|
38
|
-
uses: actions/checkout@v4
|
|
39
|
-
- name: nodejsscan scan
|
|
40
|
-
id: njsscan
|
|
41
|
-
uses: ajinabraham/njsscan-action@master
|
|
42
|
-
with:
|
|
43
|
-
args: '.'
|
|
44
|
-
|
|
45
|
-
license-scan:
|
|
46
|
-
name: License compliance check
|
|
47
|
-
runs-on: ubuntu-latest
|
|
48
|
-
|
|
49
|
-
steps:
|
|
50
|
-
- uses: actions/checkout@v4
|
|
51
|
-
- uses: mikaelvesavuori/license-compliance-action@v1.0.2
|
|
52
|
-
with:
|
|
53
|
-
exclude_pattern: /^@natlibfi/
|
|
54
|
-
|
|
55
|
-
publish:
|
|
56
|
-
runs-on: ubuntu-latest
|
|
57
|
-
needs: [build-node-versions, njsscan]
|
|
58
|
-
if: contains(github.ref, 'refs/tags/')
|
|
59
|
-
|
|
60
|
-
steps:
|
|
61
|
-
- uses: actions/checkout@v4
|
|
62
|
-
# Setup .npmrc file to publish to npm
|
|
63
|
-
- uses: actions/setup-node@v4
|
|
64
|
-
with:
|
|
65
|
-
node-version: '18.x'
|
|
66
|
-
registry-url: 'https://registry.npmjs.org'
|
|
67
|
-
- run: npm i
|
|
68
|
-
- run: npm publish
|
|
69
|
-
env:
|
|
70
|
-
NODE_AUTH_TOKEN: ${{ secrets.ORACLEDB_MOCK_NPM_TOKEN }}
|
package/dist/index.spec.js
DELETED
|
@@ -1,92 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _ = _interopRequireDefault(require("."));
|
|
4
|
-
var _fixugen = _interopRequireDefault(require("@natlibfi/fixugen"));
|
|
5
|
-
var _chai = require("chai");
|
|
6
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
7
|
-
/**
|
|
8
|
-
*
|
|
9
|
-
* @licstart The following is the entire license notice for the JavaScript code in this file.
|
|
10
|
-
*
|
|
11
|
-
* A mock for oracledb Node.js module
|
|
12
|
-
*
|
|
13
|
-
* Copyright (C) 2020 University Of Helsinki (The National Library Of Finland)
|
|
14
|
-
*
|
|
15
|
-
* This file is part of oracledb-mock-js
|
|
16
|
-
*
|
|
17
|
-
* oracledb-mock-js program is free software: you can redistribute it and/or modify
|
|
18
|
-
* it under the terms of the GNU Affero General Public License as
|
|
19
|
-
* published by the Free Software Foundation, either version 3 of the
|
|
20
|
-
* License, or (at your option) any later version.
|
|
21
|
-
*
|
|
22
|
-
* oracledb-mock-js is distributed in the hope that it will be useful,
|
|
23
|
-
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
24
|
-
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
25
|
-
* GNU Affero General Public License for more details.
|
|
26
|
-
*
|
|
27
|
-
* You should have received a copy of the GNU Affero General Public License
|
|
28
|
-
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
29
|
-
*
|
|
30
|
-
* @licend The above is the entire license notice
|
|
31
|
-
* for the JavaScript code in this file.
|
|
32
|
-
*
|
|
33
|
-
*/
|
|
34
|
-
|
|
35
|
-
(0, _fixugen.default)({
|
|
36
|
-
useMetadataFile: true,
|
|
37
|
-
path: [__dirname, '..', 'test-fixtures'],
|
|
38
|
-
callback: async ({
|
|
39
|
-
dbResults,
|
|
40
|
-
usePool = false,
|
|
41
|
-
expectedResults,
|
|
42
|
-
query,
|
|
43
|
-
args = {}
|
|
44
|
-
}) => {
|
|
45
|
-
const mock = (0, _.default)();
|
|
46
|
-
mock._execute(formatDbResults());
|
|
47
|
-
if (usePool) {
|
|
48
|
-
const pool = await mock.createPool();
|
|
49
|
-
const connection = await pool.getConnection();
|
|
50
|
-
const {
|
|
51
|
-
resultSet
|
|
52
|
-
} = await connection.execute(query, args);
|
|
53
|
-
const results = await fetchResults(resultSet);
|
|
54
|
-
(0, _chai.expect)(results).to.eql(expectedResults);
|
|
55
|
-
await connection.close();
|
|
56
|
-
await pool.close();
|
|
57
|
-
mock._clear();
|
|
58
|
-
return;
|
|
59
|
-
}
|
|
60
|
-
const connection = await mock.getConnection();
|
|
61
|
-
const {
|
|
62
|
-
resultSet
|
|
63
|
-
} = await connection.execute(query, args);
|
|
64
|
-
const results = await fetchResults(resultSet);
|
|
65
|
-
(0, _chai.expect)(results).to.eql(expectedResults);
|
|
66
|
-
await connection.close();
|
|
67
|
-
mock._clear();
|
|
68
|
-
async function fetchResults(resultSet, results = []) {
|
|
69
|
-
const row = await resultSet.getRow();
|
|
70
|
-
if (row) {
|
|
71
|
-
return fetchResults(resultSet, results.concat(row));
|
|
72
|
-
}
|
|
73
|
-
await resultSet.close();
|
|
74
|
-
return results;
|
|
75
|
-
}
|
|
76
|
-
function formatDbResults() {
|
|
77
|
-
return dbResults.map(({
|
|
78
|
-
queryPattern,
|
|
79
|
-
...rest
|
|
80
|
-
}) => {
|
|
81
|
-
if (queryPattern) {
|
|
82
|
-
return {
|
|
83
|
-
...rest,
|
|
84
|
-
queryPattern: new RegExp(queryPattern, 'u')
|
|
85
|
-
};
|
|
86
|
-
}
|
|
87
|
-
return rest;
|
|
88
|
-
});
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
});
|
|
92
|
-
//# sourceMappingURL=index.spec.js.map
|
package/dist/index.spec.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.spec.js","names":["_","_interopRequireDefault","require","_fixugen","_chai","obj","__esModule","default","generateTests","useMetadataFile","path","__dirname","callback","dbResults","usePool","expectedResults","query","args","mock","createMock","_execute","formatDbResults","pool","createPool","connection","getConnection","resultSet","execute","results","fetchResults","expect","to","eql","close","_clear","row","getRow","concat","map","queryPattern","rest","RegExp"],"sources":["../src/index.spec.js"],"sourcesContent":["/**\n*\n* @licstart The following is the entire license notice for the JavaScript code in this file.\n*\n* A mock for oracledb Node.js module\n*\n* Copyright (C) 2020 University Of Helsinki (The National Library Of Finland)\n*\n* This file is part of oracledb-mock-js\n*\n* oracledb-mock-js program is free software: you can redistribute it and/or modify\n* it under the terms of the GNU Affero General Public License as\n* published by the Free Software Foundation, either version 3 of the\n* License, or (at your option) any later version.\n*\n* oracledb-mock-js is distributed in the hope that it will be useful,\n* but WITHOUT ANY WARRANTY; without even the implied warranty of\n* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n* GNU Affero General Public License for more details.\n*\n* You should have received a copy of the GNU Affero General Public License\n* along with this program. If not, see <http://www.gnu.org/licenses/>.\n*\n* @licend The above is the entire license notice\n* for the JavaScript code in this file.\n*\n*/\n\nimport createMock from '.';\nimport generateTests from '@natlibfi/fixugen';\nimport {expect} from 'chai';\n\ngenerateTests({\n useMetadataFile: true,\n path: [__dirname, '..', 'test-fixtures'],\n callback: async ({dbResults, usePool = false, expectedResults, query, args = {}}) => {\n const mock = createMock();\n\n mock._execute(formatDbResults());\n\n if (usePool) {\n const pool = await mock.createPool();\n const connection = await pool.getConnection();\n const {resultSet} = await connection.execute(query, args);\n const results = await fetchResults(resultSet);\n\n expect(results).to.eql(expectedResults);\n\n await connection.close();\n await pool.close();\n\n mock._clear();\n return;\n }\n\n const connection = await mock.getConnection();\n const {resultSet} = await connection.execute(query, args);\n const results = await fetchResults(resultSet);\n\n expect(results).to.eql(expectedResults);\n\n await connection.close();\n mock._clear();\n\n async function fetchResults(resultSet, results = []) {\n const row = await resultSet.getRow();\n\n if (row) {\n return fetchResults(resultSet, results.concat(row));\n }\n\n await resultSet.close();\n return results;\n }\n\n function formatDbResults() {\n return dbResults.map(({queryPattern, ...rest}) => {\n if (queryPattern) {\n return {\n ...rest,\n queryPattern: new RegExp(queryPattern, 'u')\n };\n }\n\n return rest;\n });\n }\n }\n});\n"],"mappings":";;AA4BA,IAAAA,CAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,QAAA,GAAAF,sBAAA,CAAAC,OAAA;AACA,IAAAE,KAAA,GAAAF,OAAA;AAA4B,SAAAD,uBAAAI,GAAA,WAAAA,GAAA,IAAAA,GAAA,CAAAC,UAAA,GAAAD,GAAA,KAAAE,OAAA,EAAAF,GAAA;AA9B5B;AACA;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