@natlibfi/oracledb-mock 1.0.0 → 1.0.2-alpha.1

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.
@@ -0,0 +1,2 @@
1
+ # With this line @NatLibFi/melinda-js-lead owns any files in this repository
2
+ * @NatLibFi/melinda-js-lead
@@ -0,0 +1,40 @@
1
+ # NatLibFi/Melinda maintenance strategy
2
+ # https://docs.github.com/en/code-security/supply-chain-security/keeping-your-dependencies-updated-automatically/configuration-options-for-dependency-updates
3
+
4
+ version: 2
5
+ updates:
6
+ # Maintain dependencies for GitHub Actions
7
+ - package-ecosystem: "github-actions"
8
+ directory: "/"
9
+ schedule:
10
+ interval: "daily"
11
+ time: "06:30"
12
+ timezone: "Europe/Helsinki"
13
+ target-branch: "dependencies"
14
+
15
+ # Minor updates to npm production dependencies daily
16
+ - package-ecosystem: "npm"
17
+ directory: "/"
18
+ schedule:
19
+ interval: "daily"
20
+ time: "06:45"
21
+ timezone: "Europe/Helsinki"
22
+ versioning-strategy: lockfile-only
23
+ allow:
24
+ - dependency-type: "production"
25
+ target-branch: "dependencies"
26
+
27
+ # Major updates to npm dependencies weekly @tuesday
28
+ # Not possible yet https://github.com/dependabot/dependabot-core/issues/1778
29
+ # - package-ecosystem: "npm"
30
+ # directory: "/"
31
+ # schedule:
32
+ # interval: "weekly"
33
+ # day: "tuesday"
34
+ # time: "07:00"
35
+ # timezone: "Europe/Helsinki"
36
+ # versioning-strategy: increase-if-necessary
37
+ # labels:
38
+ # - "npm major dependencies"
39
+ # reviewers:
40
+ # - "natlibfi/melinda-js-lead"
@@ -0,0 +1,70 @@
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]
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@v3
20
+ - name: Use Node.js ${{ matrix.node-version }}
21
+ uses: actions/setup-node@v3
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@v3
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@v3
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@v3
62
+ # Setup .npmrc file to publish to npm
63
+ - uses: actions/setup-node@v3
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.js CHANGED
@@ -4,11 +4,8 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = void 0;
7
-
8
7
  var _deepEql = _interopRequireDefault(require("deep-eql"));
9
-
10
8
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
11
-
12
9
  /**
13
10
  *
14
11
  * @licstart The following is the entire license notice for the JavaScript code in this file.
@@ -54,7 +51,6 @@ var _default = () => {
54
51
  getRow: () => rows.shift(),
55
52
  // eslint-disable-line functional/immutable-data
56
53
  close: () => {} // eslint-disable-line no-empty-function
57
-
58
54
  }
59
55
  };
60
56
 
@@ -66,18 +62,14 @@ var _default = () => {
66
62
  if (queryPattern.test(query) && (expectedArgs === undefined || (0, _deepEql.default)(args, expectedArgs))) {
67
63
  return true;
68
64
  }
69
-
70
65
  return false;
71
66
  });
72
-
73
67
  if (index >= 0) {
74
68
  const {
75
69
  results
76
70
  } = options.splice(index, 1).shift(); // eslint-disable-line functional/immutable-data
77
-
78
71
  return results;
79
72
  }
80
-
81
73
  return [];
82
74
  }
83
75
  }
@@ -87,26 +79,26 @@ var _default = () => {
87
79
  createPool: () => ({
88
80
  getConnection: () => connection,
89
81
  close: () => {} // eslint-disable-line no-empty-function
90
-
91
82
  }),
83
+
92
84
  _clear: () => {
93
85
  // Clear array
94
86
  options.splice(0); // eslint-disable-line functional/immutable-data
95
-
96
87
  Object.keys(options).forEach(k => delete options[k]); // eslint-disable-line functional/immutable-data
97
88
  },
89
+
98
90
  _execute: optList => {
99
91
  // Clear array
100
92
  options.splice(0); // eslint-disable-line functional/immutable-data
101
93
 
102
94
  optList.forEach(opts => {
103
- options.push({ ...DEFAULT_OPTIONS,
95
+ options.push({
96
+ ...DEFAULT_OPTIONS,
104
97
  ...opts
105
98
  }); // eslint-disable-line functional/immutable-data
106
99
  });
107
100
  }
108
101
  };
109
102
  };
110
-
111
103
  exports.default = _default;
112
104
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.js"],"names":["options","DEFAULT_OPTIONS","queryPattern","results","connection","close","break","execute","query","args","rows","getRows","resultSet","getRow","shift","index","findIndex","expectedArgs","test","undefined","splice","getConnection","createPool","_clear","Object","keys","forEach","k","_execute","optList","opts","push"],"mappings":";;;;;;;AA4BA;;;;AA5BA;;;;;;;;;;;;;;;;;;;;;;;;;;;eA8Be,MAAM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K,EAAE,MAAM,CAAE,CAFE,CAED;;AAFC,KAAP,CAFP;AAMLkB,IAAAA,MAAM,EAAE,MAAM;AACZ;AACAvB,MAAAA,OAAO,CAACoB,MAAR,CAAe,CAAf,EAFY,CAEO;;AACnBI,MAAAA,MAAM,CAACC,IAAP,CAAYzB,OAAZ,EAAqB0B,OAArB,CAA6BC,CAAC,IAAI,OAAO3B,OAAO,CAAC2B,CAAD,CAAhD,EAHY,CAG0C;AACvD,KAVI;AAWLC,IAAAA,QAAQ,EAAEC,OAAO,IAAI;AACnB;AACA7B,MAAAA,OAAO,CAACoB,MAAR,CAAe,CAAf,EAFmB,CAEA;;AAEnBS,MAAAA,OAAO,CAACH,OAAR,CAAgBI,IAAI,IAAI;AACtB9B,QAAAA,OAAO,CAAC+B,IAAR,CAAa,EAAC,GAAG9B,eAAJ;AAAqB,aAAG6B;AAAxB,SAAb,EADsB,CACuB;AAC9C,OAFD;AAGD;AAlBI,GAAP;AAoBD,C","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: () => {}, // eslint-disable-line no-empty-function\n break: () => {}, // eslint-disable-line no-empty-function\n execute: (query, args) => {\n const rows = getRows();\n\n return {\n resultSet: {\n getRow: () => rows.shift(), // eslint-disable-line functional/immutable-data\n close: () => {} // eslint-disable-line no-empty-function\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(); // eslint-disable-line functional/immutable-data\n return results;\n }\n\n return [];\n }\n }\n };\n\n return {\n getConnection: () => connection,\n createPool: () => ({\n getConnection: () => connection,\n close: () => {} // eslint-disable-line no-empty-function\n }),\n _clear: () => {\n // Clear array\n options.splice(0); // eslint-disable-line functional/immutable-data\n Object.keys(options).forEach(k => delete options[k]); // eslint-disable-line functional/immutable-data\n },\n _execute: optList => {\n // Clear array\n options.splice(0); // eslint-disable-line functional/immutable-data\n\n optList.forEach(opts => {\n options.push({...DEFAULT_OPTIONS, ...opts}); // eslint-disable-line functional/immutable-data\n });\n }\n };\n};\n"],"file":"index.js"}
1
+ {"version":3,"file":"index.js","names":["_deepEql","_interopRequireDefault","require","obj","__esModule","default","_default","options","DEFAULT_OPTIONS","queryPattern","results","connection","close","break","execute","query","args","rows","getRows","resultSet","getRow","shift","index","findIndex","expectedArgs","test","undefined","deepEqual","splice","getConnection","createPool","_clear","Object","keys","forEach","k","_execute","optList","opts","push","exports"],"sources":["../src/index.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 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: () => {}, // eslint-disable-line no-empty-function\n break: () => {}, // eslint-disable-line no-empty-function\n execute: (query, args) => {\n const rows = getRows();\n\n return {\n resultSet: {\n getRow: () => rows.shift(), // eslint-disable-line functional/immutable-data\n close: () => {} // eslint-disable-line no-empty-function\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(); // eslint-disable-line functional/immutable-data\n return results;\n }\n\n return [];\n }\n }\n };\n\n return {\n getConnection: () => connection,\n createPool: () => ({\n getConnection: () => connection,\n close: () => {} // eslint-disable-line no-empty-function\n }),\n _clear: () => {\n // Clear array\n options.splice(0); // eslint-disable-line functional/immutable-data\n Object.keys(options).forEach(k => delete options[k]); // eslint-disable-line functional/immutable-data\n },\n _execute: optList => {\n // Clear array\n options.splice(0); // eslint-disable-line functional/immutable-data\n\n optList.forEach(opts => {\n options.push({...DEFAULT_OPTIONS, ...opts}); // eslint-disable-line functional/immutable-data\n });\n }\n };\n};\n"],"mappings":";;;;;;AA4BA,IAAAA,QAAA,GAAAC,sBAAA,CAAAC,OAAA;AAAiC,SAAAD,uBAAAE,GAAA,WAAAA,GAAA,IAAAA,GAAA,CAAAC,UAAA,GAAAD,GAAA,KAAAE,OAAA,EAAAF,GAAA;AA5BjC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;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BmB,UAAU,EAAEA,CAAA,MAAO;MACjBD,aAAa,EAAEA,CAAA,KAAMlB,UAAU;MAC/BC,KAAK,EAAEA,CAAA,KAAM,CAAC,CAAC,CAAC;IAClB,CAAC,CAAC;;IACFmB,MAAM,EAAEA,CAAA,KAAM;MACZ;MACAxB,OAAO,CAACqB,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC;MACnBI,MAAM,CAACC,IAAI,CAAC1B,OAAO,CAAC,CAAC2B,OAAO,CAACC,CAAC,IAAI,OAAO5B,OAAO,CAAC4B,CAAC,CAAC,CAAC,CAAC,CAAC;IACxD,CAAC;;IACDC,QAAQ,EAAEC,OAAO,IAAI;MACnB;MACA9B,OAAO,CAACqB,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC;;MAEnBS,OAAO,CAACH,OAAO,CAACI,IAAI,IAAI;QACtB/B,OAAO,CAACgC,IAAI,CAAC;UAAC,GAAG/B,eAAe;UAAE,GAAG8B;QAAI,CAAC,CAAC,CAAC,CAAC;MAC/C,CAAC,CAAC;IACJ;EACF,CAAC;AACH,CAAC;AAAAE,OAAA,CAAAnC,OAAA,GAAAC,QAAA"}
@@ -1,13 +1,9 @@
1
1
  "use strict";
2
2
 
3
3
  var _ = _interopRequireDefault(require("."));
4
-
5
4
  var _fixugen = _interopRequireDefault(require("@natlibfi/fixugen"));
6
-
7
5
  var _chai = require("chai");
8
-
9
6
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
10
-
11
7
  /**
12
8
  *
13
9
  * @licstart The following is the entire license notice for the JavaScript code in this file.
@@ -35,6 +31,7 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
35
31
  * for the JavaScript code in this file.
36
32
  *
37
33
  */
34
+
38
35
  (0, _fixugen.default)({
39
36
  useMetadataFile: true,
40
37
  path: [__dirname, '..', 'test-fixtures'],
@@ -46,9 +43,7 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
46
43
  args = {}
47
44
  }) => {
48
45
  const mock = (0, _.default)();
49
-
50
46
  mock._execute(formatDbResults());
51
-
52
47
  if (usePool) {
53
48
  const pool = await mock.createPool();
54
49
  const connection = await pool.getConnection();
@@ -59,12 +54,9 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
59
54
  (0, _chai.expect)(results).to.eql(expectedResults);
60
55
  await connection.close();
61
56
  await pool.close();
62
-
63
57
  mock._clear();
64
-
65
58
  return;
66
59
  }
67
-
68
60
  const connection = await mock.getConnection();
69
61
  const {
70
62
  resultSet
@@ -72,31 +64,26 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
72
64
  const results = await fetchResults(resultSet);
73
65
  (0, _chai.expect)(results).to.eql(expectedResults);
74
66
  await connection.close();
75
-
76
67
  mock._clear();
77
-
78
68
  async function fetchResults(resultSet, results = []) {
79
69
  const row = await resultSet.getRow();
80
-
81
70
  if (row) {
82
71
  return fetchResults(resultSet, results.concat(row));
83
72
  }
84
-
85
73
  await resultSet.close();
86
74
  return results;
87
75
  }
88
-
89
76
  function formatDbResults() {
90
77
  return dbResults.map(({
91
78
  queryPattern,
92
79
  ...rest
93
80
  }) => {
94
81
  if (queryPattern) {
95
- return { ...rest,
82
+ return {
83
+ ...rest,
96
84
  queryPattern: new RegExp(queryPattern, 'u')
97
85
  };
98
86
  }
99
-
100
87
  return rest;
101
88
  });
102
89
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.spec.js"],"names":["useMetadataFile","path","__dirname","callback","dbResults","usePool","expectedResults","query","args","mock","_execute","formatDbResults","pool","createPool","connection","getConnection","resultSet","execute","results","fetchResults","to","eql","close","_clear","row","getRow","concat","map","queryPattern","rest","RegExp"],"mappings":";;AA4BA;;AACA;;AACA;;;;AA9BA;;;;;;;;;;;;;;;;;;;;;;;;;;;AAgCA,sBAAc;AACZA,EAAAA,eAAe,EAAE,IADL;AAEZC,EAAAA,IAAI,EAAE,CAACC,SAAD,EAAY,IAAZ,EAAkB,eAAlB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AV,EAAlB;;AAEA,UAAID,GAAJ,EAAS;AACP,eAAOL,YAAY,CAACH,SAAD,EAAYE,OAAO,CAACQ,MAAR,CAAeF,GAAf,CAAZ,CAAnB;AACD;;AAED,YAAMR,SAAS,CAACM,KAAV,EAAN;AACA,aAAOJ,OAAP;AACD;;AAED,aAASP,eAAT,GAA2B;AACzB,aAAOP,SAAS,CAACuB,GAAV,CAAc,CAAC;AAACC,QAAAA,YAAD;AAAe,WAAGC;AAAlB,OAAD,KAA6B;AAChD,YAAID,YAAJ,EAAkB;AAChB,iBAAO,EACL,GAAGC,IADE;AAELD,YAAAA,YAAY,EAAE,IAAIE,MAAJ,CAAWF,YAAX,EAAyB,GAAzB;AAFT,WAAP;AAID;;AAED,eAAOC,IAAP;AACD,OATM,CAAP;AAUD;AACF;AAvDW,CAAd","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"],"file":"index.spec.js"}
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;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;;AAMA,IAAAG,gBAAa,EAAC;EACZC,eAAe,EAAE,IAAI;EACrBC,IAAI,EAAE,CAACC,SAAS,EAAE,IAAI,EAAE,eAAe,CAAC;EACxCC,QAAQ,EAAE,MA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,MAAM,CAAC,CAAC;MAEpC,IAAID,GAAG,EAAE;QACP,OAAON,YAAY,CAACH,SAAS,EAAEE,OAAO,CAACS,MAAM,CAACF,GAAG,CAAC,CAAC;MACrD;MAEA,MAAMT,SAAS,CAACO,KAAK,CAAC,CAAC;MACvB,OAAOL,OAAO;IAChB;IAEA,SAASP,eAAeA,CAAA,EAAG;MACzB,OAAOR,SAAS,CAACyB,GAAG,CAAC,CAAC;QAACC,YAAY;QAAE,GAAGC;MAAI,CAAC,KAAK;QAChD,IAAID,YAAY,EAAE;UAChB,OAAO;YACL,GAAGC,IAAI;YACPD,YAAY,EAAE,IAAIE,MAAM,CAACF,YAAY,EAAE,GAAG;UAC5C,CAAC;QACH;QAEA,OAAOC,IAAI;MACb,CAAC,CAAC;IACJ;EACF;AACF,CAAC,CAAC"}
package/package.json CHANGED
@@ -14,7 +14,7 @@
14
14
  "url": "git@github.com:natlibfi/oracledb-mock-js.git"
15
15
  },
16
16
  "license": "LGPL-3.0+",
17
- "version": "1.0.0",
17
+ "version": "1.0.2-alpha.1",
18
18
  "main": "./dist/index.js",
19
19
  "engines": {
20
20
  "node": ">=12"
@@ -23,6 +23,7 @@
23
23
  "access": "public"
24
24
  },
25
25
  "scripts": {
26
+ "prepare": "npm run build",
26
27
  "lint": "eslint src",
27
28
  "lint:dev": "eslint --fix src",
28
29
  "test:base": "cross-env NODE_ENV=test nyc mocha --require @babel/register",
@@ -36,22 +37,22 @@
36
37
  "deep-eql": "^4.0.0"
37
38
  },
38
39
  "devDependencies": {
39
- "@babel/cli": "^7.10.1",
40
- "@babel/core": "^7.10.1",
41
- "@babel/node": "^7.10.1",
42
- "@babel/preset-env": "^7.10.1",
43
- "@babel/register": "^7.10.1",
44
- "@natlibfi/eslint-config-melinda-backend": "^1.0.3",
45
- "@natlibfi/fixugen": "^1.0.0",
46
- "@natlibfi/fixura": "^2.1.2",
47
- "babel-eslint": "^10.1.0",
40
+ "@babel/cli": "^7.22.9",
41
+ "@babel/core": "^7.22.9",
42
+ "@babel/eslint-parser": "^7.22.9",
43
+ "@babel/node": "^7.22.6",
44
+ "@babel/preset-env": "^7.22.9",
45
+ "@babel/register": "^7.22.5",
46
+ "@natlibfi/eslint-config-melinda-backend": "^3.0.0",
47
+ "@natlibfi/fixugen": "^2.0.0",
48
+ "@natlibfi/fixura": "^3.0.0",
48
49
  "babel-plugin-istanbul": "^6.0.0",
49
50
  "chai": "^4.2.0",
50
51
  "cross-env": "^7.0.2",
51
- "eslint": "^7.0.0",
52
- "mocha": "^7.1.2",
53
- "nodemon": "^2.0.4",
54
- "nyc": "^15.0.1"
52
+ "eslint": "^8.45.0",
53
+ "mocha": "^10.2.0",
54
+ "nodemon": "^3.0.1",
55
+ "nyc": "^15.1.0"
55
56
  },
56
57
  "eslintConfig": {
57
58
  "extends": "@natlibfi/melinda-backend"
@@ -61,9 +62,7 @@
61
62
  [
62
63
  "@babel/preset-env",
63
64
  {
64
- "targets": {
65
- "node": "12"
66
- }
65
+ "targets": "maintained node versions"
67
66
  }
68
67
  ]
69
68
  ],
@@ -80,8 +79,7 @@
80
79
  "*/*.spec.js"
81
80
  ],
82
81
  "reporter": [
83
- "lcov",
84
- "html"
82
+ "text"
85
83
  ],
86
84
  "require": [
87
85
  "@babel/register"