From 569498a29f4e9794e32917d80c308e65bed618ad Mon Sep 17 00:00:00 2001 From: Alan Cruikshanks Date: Thu, 5 Jan 2023 08:41:33 +0000 Subject: [PATCH 1/9] Restructure models by type and scheme https://github.com/DEFRA/water-abstraction-team/issues/69 Our next step in refactoring the models to deal with legacy issues is to identify them by type and scheme. Admittedly, we know we are just dealing with the one type (legacy) and scheme (water). But more will be coming and this helps set the groundwork for implementing base classes that allow us to start hiding some of the issues with the existing DB. So, we move the existing models into a new `models/water` folder and we add a new `LegacyModel` which all our existing classes will inherit from. From 356de5bd7dc29d70a248a5b36b9242e8043125c6 Mon Sep 17 00:00:00 2001 From: Alan Cruikshanks Date: Thu, 5 Jan 2023 14:32:05 +0000 Subject: [PATCH 2/9] Move models into scheme folder --- app/models/{ => water}/billing-batch.model.js | 2 +- app/models/{ => water}/billing-charge-category.model.js | 2 +- app/models/{ => water}/charge-element.model.js | 2 +- app/models/{ => water}/charge-purpose.model.js | 2 +- app/models/{ => water}/charge-version.model.js | 2 +- app/models/{ => water}/event.model.js | 2 +- app/models/{ => water}/licence.model.js | 2 +- app/models/{ => water}/region.model.js | 2 +- 8 files changed, 8 insertions(+), 8 deletions(-) rename app/models/{ => water}/billing-batch.model.js (92%) rename app/models/{ => water}/billing-charge-category.model.js (93%) rename app/models/{ => water}/charge-element.model.js (96%) rename app/models/{ => water}/charge-purpose.model.js (93%) rename app/models/{ => water}/charge-version.model.js (94%) rename app/models/{ => water}/event.model.js (83%) rename app/models/{ => water}/licence.model.js (94%) rename app/models/{ => water}/region.model.js (94%) diff --git a/app/models/billing-batch.model.js b/app/models/water/billing-batch.model.js similarity index 92% rename from app/models/billing-batch.model.js rename to app/models/water/billing-batch.model.js index aecdc13ebb..e5fde201f2 100644 --- a/app/models/billing-batch.model.js +++ b/app/models/water/billing-batch.model.js @@ -7,7 +7,7 @@ const { Model } = require('objection') -const BaseModel = require('./base.model.js') +const BaseModel = require('../base.model.js') class BillingBatchModel extends BaseModel { static get tableName () { diff --git a/app/models/billing-charge-category.model.js b/app/models/water/billing-charge-category.model.js similarity index 93% rename from app/models/billing-charge-category.model.js rename to app/models/water/billing-charge-category.model.js index 23f9c2a40a..7f713ed1b8 100644 --- a/app/models/billing-charge-category.model.js +++ b/app/models/water/billing-charge-category.model.js @@ -7,7 +7,7 @@ const { Model } = require('objection') -const BaseModel = require('./base.model.js') +const BaseModel = require('../base.model.js') class BillingChargeCategoryModel extends BaseModel { static get tableName () { diff --git a/app/models/charge-element.model.js b/app/models/water/charge-element.model.js similarity index 96% rename from app/models/charge-element.model.js rename to app/models/water/charge-element.model.js index a49453b91a..1855c0c5af 100644 --- a/app/models/charge-element.model.js +++ b/app/models/water/charge-element.model.js @@ -7,7 +7,7 @@ const { Model } = require('objection') -const BaseModel = require('./base.model.js') +const BaseModel = require('../base.model.js') class ChargeElementModel extends BaseModel { static get tableName () { diff --git a/app/models/charge-purpose.model.js b/app/models/water/charge-purpose.model.js similarity index 93% rename from app/models/charge-purpose.model.js rename to app/models/water/charge-purpose.model.js index b103081aa8..1a712eb4c8 100644 --- a/app/models/charge-purpose.model.js +++ b/app/models/water/charge-purpose.model.js @@ -7,7 +7,7 @@ const { Model } = require('objection') -const BaseModel = require('./base.model.js') +const BaseModel = require('../base.model.js') class ChargePurposeModel extends BaseModel { static get tableName () { diff --git a/app/models/charge-version.model.js b/app/models/water/charge-version.model.js similarity index 94% rename from app/models/charge-version.model.js rename to app/models/water/charge-version.model.js index d7f9307524..4b1b053606 100644 --- a/app/models/charge-version.model.js +++ b/app/models/water/charge-version.model.js @@ -7,7 +7,7 @@ const { Model } = require('objection') -const BaseModel = require('./base.model.js') +const BaseModel = require('../base.model.js') class ChargeVersionModel extends BaseModel { static get tableName () { diff --git a/app/models/event.model.js b/app/models/water/event.model.js similarity index 83% rename from app/models/event.model.js rename to app/models/water/event.model.js index b393a509db..de46608532 100644 --- a/app/models/event.model.js +++ b/app/models/water/event.model.js @@ -5,7 +5,7 @@ * @module EventModel */ -const BaseModel = require('./base.model.js') +const BaseModel = require('../base.model.js') class EventModel extends BaseModel { static get tableName () { diff --git a/app/models/licence.model.js b/app/models/water/licence.model.js similarity index 94% rename from app/models/licence.model.js rename to app/models/water/licence.model.js index 2ef8a94c4b..e98d40cd18 100644 --- a/app/models/licence.model.js +++ b/app/models/water/licence.model.js @@ -7,7 +7,7 @@ const { Model } = require('objection') -const BaseModel = require('./base.model.js') +const BaseModel = require('../base.model.js') class LicenceModel extends BaseModel { static get tableName () { diff --git a/app/models/region.model.js b/app/models/water/region.model.js similarity index 94% rename from app/models/region.model.js rename to app/models/water/region.model.js index d29b5c5d89..45123d7492 100644 --- a/app/models/region.model.js +++ b/app/models/water/region.model.js @@ -7,7 +7,7 @@ const { Model } = require('objection') -const BaseModel = require('./base.model.js') +const BaseModel = require('../base.model.js') class RegionModel extends BaseModel { static get tableName () { From c5ea0890070b4e99bbd931bf871ad75b0b7f70f9 Mon Sep 17 00:00:00 2001 From: Alan Cruikshanks Date: Thu, 5 Jan 2023 14:39:03 +0000 Subject: [PATCH 3/9] Move the test helpers into a scheme folder --- test/support/helpers/{ => water}/billing-batch.helper.js | 2 +- .../helpers/{ => water}/billing-charge-category.helper.js | 2 +- test/support/helpers/{ => water}/charge-element.helper.js | 2 +- test/support/helpers/{ => water}/charge-purpose.helper.js | 2 +- test/support/helpers/{ => water}/charge-version.helper.js | 2 +- test/support/helpers/{ => water}/event.helper.js | 2 +- test/support/helpers/{ => water}/licence.helper.js | 2 +- test/support/helpers/{ => water}/region.helper.js | 2 +- 8 files changed, 8 insertions(+), 8 deletions(-) rename test/support/helpers/{ => water}/billing-batch.helper.js (94%) rename test/support/helpers/{ => water}/billing-charge-category.helper.js (94%) rename test/support/helpers/{ => water}/charge-element.helper.js (95%) rename test/support/helpers/{ => water}/charge-purpose.helper.js (96%) rename test/support/helpers/{ => water}/charge-version.helper.js (95%) rename test/support/helpers/{ => water}/event.helper.js (95%) rename test/support/helpers/{ => water}/licence.helper.js (93%) rename test/support/helpers/{ => water}/region.helper.js (94%) diff --git a/test/support/helpers/billing-batch.helper.js b/test/support/helpers/water/billing-batch.helper.js similarity index 94% rename from test/support/helpers/billing-batch.helper.js rename to test/support/helpers/water/billing-batch.helper.js index 46ee0e75c6..0b21968cc8 100644 --- a/test/support/helpers/billing-batch.helper.js +++ b/test/support/helpers/water/billing-batch.helper.js @@ -4,7 +4,7 @@ * @module BillingBatchHelper */ -const BillingBatchModel = require('../../../app/models/billing-batch.model.js') +const BillingBatchModel = require('../../../../app/models/water/billing-batch.model.js') /** * Add a new billing batch diff --git a/test/support/helpers/billing-charge-category.helper.js b/test/support/helpers/water/billing-charge-category.helper.js similarity index 94% rename from test/support/helpers/billing-charge-category.helper.js rename to test/support/helpers/water/billing-charge-category.helper.js index e5c8d54ef2..5e3089e2c6 100644 --- a/test/support/helpers/billing-charge-category.helper.js +++ b/test/support/helpers/water/billing-charge-category.helper.js @@ -4,7 +4,7 @@ * @module BillingChargeCategoryHelper */ -const BillingChargeCategoryModel = require('../../../app/models/billing-charge-category.model.js') +const BillingChargeCategoryModel = require('../../../../app/models/water/billing-charge-category.model.js') /** * Add a new billing charge category diff --git a/test/support/helpers/charge-element.helper.js b/test/support/helpers/water/charge-element.helper.js similarity index 95% rename from test/support/helpers/charge-element.helper.js rename to test/support/helpers/water/charge-element.helper.js index d90f9f18fb..909e6f746f 100644 --- a/test/support/helpers/charge-element.helper.js +++ b/test/support/helpers/water/charge-element.helper.js @@ -4,7 +4,7 @@ * @module ChargeElementHelper */ -const ChargeElementModel = require('../../../app/models/charge-element.model.js') +const ChargeElementModel = require('../../../../app/models/water/charge-element.model.js') /** * Add a new charge element diff --git a/test/support/helpers/charge-purpose.helper.js b/test/support/helpers/water/charge-purpose.helper.js similarity index 96% rename from test/support/helpers/charge-purpose.helper.js rename to test/support/helpers/water/charge-purpose.helper.js index 6b0c1f175d..53b1f2db47 100644 --- a/test/support/helpers/charge-purpose.helper.js +++ b/test/support/helpers/water/charge-purpose.helper.js @@ -4,7 +4,7 @@ * @module ChargePurposeHelper */ -const ChargePurposeModel = require('../../../app/models/charge-purpose.model.js') +const ChargePurposeModel = require('../../../../app/models/water/charge-purpose.model.js') /** * Add a new charge purpose diff --git a/test/support/helpers/charge-version.helper.js b/test/support/helpers/water/charge-version.helper.js similarity index 95% rename from test/support/helpers/charge-version.helper.js rename to test/support/helpers/water/charge-version.helper.js index a88eec5947..6b12f46947 100644 --- a/test/support/helpers/charge-version.helper.js +++ b/test/support/helpers/water/charge-version.helper.js @@ -4,7 +4,7 @@ * @module ChargeVersionHelper */ -const ChargeVersionModel = require('../../../app/models/charge-version.model.js') +const ChargeVersionModel = require('../../../../app/models/water/charge-version.model.js') const LicenceHelper = require('./licence.helper.js') /** diff --git a/test/support/helpers/event.helper.js b/test/support/helpers/water/event.helper.js similarity index 95% rename from test/support/helpers/event.helper.js rename to test/support/helpers/water/event.helper.js index 9a4e5b3c4f..264ca6f635 100644 --- a/test/support/helpers/event.helper.js +++ b/test/support/helpers/water/event.helper.js @@ -4,7 +4,7 @@ * @module EventHelper */ -const EventModel = require('../../../app/models/event.model.js') +const EventModel = require('../../../../app/models/water/event.model.js') /** * Add a new event diff --git a/test/support/helpers/licence.helper.js b/test/support/helpers/water/licence.helper.js similarity index 93% rename from test/support/helpers/licence.helper.js rename to test/support/helpers/water/licence.helper.js index 26e19e9df5..0bff3e9f66 100644 --- a/test/support/helpers/licence.helper.js +++ b/test/support/helpers/water/licence.helper.js @@ -4,7 +4,7 @@ * @module LicenceHelper */ -const LicenceModel = require('../../../app/models/licence.model.js') +const LicenceModel = require('../../../../app/models/water/licence.model.js') /** * Add a new licence diff --git a/test/support/helpers/region.helper.js b/test/support/helpers/water/region.helper.js similarity index 94% rename from test/support/helpers/region.helper.js rename to test/support/helpers/water/region.helper.js index 7d308c9c55..b9248f6bb3 100644 --- a/test/support/helpers/region.helper.js +++ b/test/support/helpers/water/region.helper.js @@ -4,7 +4,7 @@ * @module RegionHelper */ -const RegionModel = require('../../../app/models/region.model.js') +const RegionModel = require('../../../../app/models/water/region.model.js') /** * Add a new region From 9e53f38f0238c883aa89a64cce8fdd0ca2fb97bb Mon Sep 17 00:00:00 2001 From: Alan Cruikshanks Date: Thu, 5 Jan 2023 17:08:53 +0000 Subject: [PATCH 4/9] Move the model tests to a water schema folder --- .../{ => water}/billing-batch.model.test.js | 10 +++++----- .../billing-charge-category.model.test.js | 10 +++++----- .../{ => water}/charge-element.model.test.js | 18 +++++++++--------- .../{ => water}/charge-purpose.model.test.js | 10 +++++----- .../{ => water}/charge-version.model.test.js | 14 +++++++------- test/models/{ => water}/event.model.test.js | 6 +++--- test/models/{ => water}/licence.model.test.js | 14 +++++++------- test/models/{ => water}/region.model.test.js | 14 +++++++------- 8 files changed, 48 insertions(+), 48 deletions(-) rename test/models/{ => water}/billing-batch.model.test.js (81%) rename test/models/{ => water}/billing-charge-category.model.test.js (82%) rename test/models/{ => water}/charge-element.model.test.js (83%) rename test/models/{ => water}/charge-purpose.model.test.js (80%) rename test/models/{ => water}/charge-version.model.test.js (83%) rename test/models/{ => water}/event.model.test.js (75%) rename test/models/{ => water}/licence.model.test.js (83%) rename test/models/{ => water}/region.model.test.js (84%) diff --git a/test/models/billing-batch.model.test.js b/test/models/water/billing-batch.model.test.js similarity index 81% rename from test/models/billing-batch.model.test.js rename to test/models/water/billing-batch.model.test.js index a8cd4c3f11..d0e73d71f2 100644 --- a/test/models/billing-batch.model.test.js +++ b/test/models/water/billing-batch.model.test.js @@ -8,13 +8,13 @@ const { describe, it, beforeEach } = exports.lab = Lab.script() const { expect } = Code // Test helpers -const BillingBatchHelper = require('../support/helpers/billing-batch.helper.js') -const DatabaseHelper = require('../support/helpers/database.helper.js') -const RegionHelper = require('../support/helpers/region.helper.js') -const RegionModel = require('../../app/models/region.model.js') +const BillingBatchHelper = require('../../support/helpers/water/billing-batch.helper.js') +const DatabaseHelper = require('../../support/helpers/database.helper.js') +const RegionHelper = require('../../support/helpers/water/region.helper.js') +const RegionModel = require('../../../app/models/water/region.model.js') // Thing under test -const BillingBatchModel = require('../../app/models/billing-batch.model.js') +const BillingBatchModel = require('../../../app/models/water/billing-batch.model.js') describe('Billing Batch model', () => { let testRecord diff --git a/test/models/billing-charge-category.model.test.js b/test/models/water/billing-charge-category.model.test.js similarity index 82% rename from test/models/billing-charge-category.model.test.js rename to test/models/water/billing-charge-category.model.test.js index 7b72888579..7c67224c00 100644 --- a/test/models/billing-charge-category.model.test.js +++ b/test/models/water/billing-charge-category.model.test.js @@ -8,13 +8,13 @@ const { describe, it, beforeEach } = exports.lab = Lab.script() const { expect } = Code // Test helpers -const BillingChargeCategoryHelper = require('../support/helpers/billing-charge-category.helper.js') -const ChargeElementHelper = require('../support/helpers/charge-element.helper.js') -const ChargeElementModel = require('../../app/models/charge-element.model.js') -const DatabaseHelper = require('../support/helpers/database.helper.js') +const BillingChargeCategoryHelper = require('../../support/helpers/water/billing-charge-category.helper.js') +const ChargeElementHelper = require('../../support/helpers/water/charge-element.helper.js') +const ChargeElementModel = require('../../../app/models/water/charge-element.model.js') +const DatabaseHelper = require('../../support/helpers/database.helper.js') // Thing under test -const BillingChargeCategoryModel = require('../../app/models/billing-charge-category.model.js') +const BillingChargeCategoryModel = require('../../../app/models/water/billing-charge-category.model.js') describe('Billing Charge Category model', () => { let testRecord diff --git a/test/models/charge-element.model.test.js b/test/models/water/charge-element.model.test.js similarity index 83% rename from test/models/charge-element.model.test.js rename to test/models/water/charge-element.model.test.js index 89d0d618ab..9d56e6a3d5 100644 --- a/test/models/charge-element.model.test.js +++ b/test/models/water/charge-element.model.test.js @@ -8,17 +8,17 @@ const { describe, it, beforeEach } = exports.lab = Lab.script() const { expect } = Code // Test helpers -const BillingChargeCategoryHelper = require('../support/helpers/billing-charge-category.helper.js') -const BillingChargeCategoryModel = require('../../app/models/billing-charge-category.model.js') -const ChargeElementHelper = require('../support/helpers/charge-element.helper.js') -const ChargePurposeHelper = require('../support/helpers/charge-purpose.helper.js') -const ChargePurposeModel = require('../../app/models/charge-purpose.model.js') -const ChargeVersionHelper = require('../support/helpers/charge-version.helper.js') -const ChargeVersionModel = require('../../app/models/charge-version.model.js') -const DatabaseHelper = require('../support/helpers/database.helper.js') +const BillingChargeCategoryHelper = require('../../support/helpers/water/billing-charge-category.helper.js') +const BillingChargeCategoryModel = require('../../../app/models/water/billing-charge-category.model.js') +const ChargeElementHelper = require('../../support/helpers/water/charge-element.helper.js') +const ChargePurposeHelper = require('../../support/helpers/water/charge-purpose.helper.js') +const ChargePurposeModel = require('../../../app/models/water/charge-purpose.model.js') +const ChargeVersionHelper = require('../../support/helpers/water/charge-version.helper.js') +const ChargeVersionModel = require('../../../app/models/water/charge-version.model.js') +const DatabaseHelper = require('../../support/helpers/database.helper.js') // Thing under test -const ChargeElementModel = require('../../app/models/charge-element.model.js') +const ChargeElementModel = require('../../../app/models/water/charge-element.model.js') describe('Charge Element model', () => { let testRecord diff --git a/test/models/charge-purpose.model.test.js b/test/models/water/charge-purpose.model.test.js similarity index 80% rename from test/models/charge-purpose.model.test.js rename to test/models/water/charge-purpose.model.test.js index fd962f6d89..168e609831 100644 --- a/test/models/charge-purpose.model.test.js +++ b/test/models/water/charge-purpose.model.test.js @@ -8,13 +8,13 @@ const { describe, it, beforeEach } = exports.lab = Lab.script() const { expect } = Code // Test helpers -const ChargeElementHelper = require('../support/helpers/charge-element.helper.js') -const ChargeElementModel = require('../../app/models/charge-element.model.js') -const ChargePurposeHelper = require('../support/helpers/charge-purpose.helper.js') -const DatabaseHelper = require('../support/helpers/database.helper.js') +const ChargeElementHelper = require('../../support/helpers/water/charge-element.helper.js') +const ChargeElementModel = require('../../../app/models/water/charge-element.model.js') +const ChargePurposeHelper = require('../../support/helpers/water/charge-purpose.helper.js') +const DatabaseHelper = require('../../support/helpers/database.helper.js') // Thing under test -const ChargePurposeModel = require('../../app/models/charge-purpose.model.js') +const ChargePurposeModel = require('../../../app/models/water/charge-purpose.model.js') describe('Charge Purpose model', () => { let testRecord diff --git a/test/models/charge-version.model.test.js b/test/models/water/charge-version.model.test.js similarity index 83% rename from test/models/charge-version.model.test.js rename to test/models/water/charge-version.model.test.js index 5a65a83ef8..b667bb91b0 100644 --- a/test/models/charge-version.model.test.js +++ b/test/models/water/charge-version.model.test.js @@ -8,15 +8,15 @@ const { describe, it, beforeEach } = exports.lab = Lab.script() const { expect } = Code // Test helpers -const ChargeElementHelper = require('../support/helpers/charge-element.helper.js') -const ChargeElementModel = require('../../app/models/charge-element.model.js') -const ChargeVersionHelper = require('../support/helpers/charge-version.helper.js') -const DatabaseHelper = require('../support/helpers/database.helper.js') -const LicenceHelper = require('../support/helpers/licence.helper.js') -const LicenceModel = require('../../app/models/licence.model.js') +const ChargeElementHelper = require('../../support/helpers/water/charge-element.helper.js') +const ChargeElementModel = require('../../../app/models/water/charge-element.model.js') +const ChargeVersionHelper = require('../../support/helpers/water/charge-version.helper.js') +const DatabaseHelper = require('../../support/helpers/database.helper.js') +const LicenceHelper = require('../../support/helpers/water/licence.helper.js') +const LicenceModel = require('../../../app/models/water/licence.model.js') // Thing under test -const ChargeVersionModel = require('../../app/models/charge-version.model.js') +const ChargeVersionModel = require('../../../app/models/water/charge-version.model.js') describe('ChargeVersion model', () => { let testRecord diff --git a/test/models/event.model.test.js b/test/models/water/event.model.test.js similarity index 75% rename from test/models/event.model.test.js rename to test/models/water/event.model.test.js index 6836cdb522..ff724b2909 100644 --- a/test/models/event.model.test.js +++ b/test/models/water/event.model.test.js @@ -8,11 +8,11 @@ const { describe, it, beforeEach } = exports.lab = Lab.script() const { expect } = Code // Test helpers -const DatabaseHelper = require('../support/helpers/database.helper.js') -const EventHelper = require('../support/helpers/event.helper.js') +const DatabaseHelper = require('../../support/helpers/database.helper.js') +const EventHelper = require('../../support/helpers/water/event.helper.js') // Thing under test -const EventModel = require('../../app/models/event.model.js') +const EventModel = require('../../../app/models/water/event.model.js') describe('Event model', () => { let testRecord diff --git a/test/models/licence.model.test.js b/test/models/water/licence.model.test.js similarity index 83% rename from test/models/licence.model.test.js rename to test/models/water/licence.model.test.js index 1d468ff943..3b78ced322 100644 --- a/test/models/licence.model.test.js +++ b/test/models/water/licence.model.test.js @@ -8,15 +8,15 @@ const { describe, it, beforeEach } = exports.lab = Lab.script() const { expect } = Code // Test helpers -const ChargeVersionHelper = require('../support/helpers/charge-version.helper.js') -const ChargeVersionModel = require('../../app/models/charge-version.model.js') -const DatabaseHelper = require('../support/helpers/database.helper.js') -const LicenceHelper = require('../support/helpers/licence.helper.js') -const RegionHelper = require('../support/helpers/region.helper.js') -const RegionModel = require('../../app/models/region.model.js') +const ChargeVersionHelper = require('../../support/helpers/water/charge-version.helper.js') +const ChargeVersionModel = require('../../../app/models/water/charge-version.model.js') +const DatabaseHelper = require('../../support/helpers/database.helper.js') +const LicenceHelper = require('../../support/helpers/water/licence.helper.js') +const RegionHelper = require('../../support/helpers/water/region.helper.js') +const RegionModel = require('../../../app/models/water/region.model.js') // Thing under test -const LicenceModel = require('../../app/models/licence.model.js') +const LicenceModel = require('../../../app/models/water/licence.model.js') describe('Licence model', () => { let testRecord diff --git a/test/models/region.model.test.js b/test/models/water/region.model.test.js similarity index 84% rename from test/models/region.model.test.js rename to test/models/water/region.model.test.js index 1c30ed6c1a..0b6c52f00c 100644 --- a/test/models/region.model.test.js +++ b/test/models/water/region.model.test.js @@ -8,15 +8,15 @@ const { describe, it, beforeEach } = exports.lab = Lab.script() const { expect } = Code // Test helpers -const BillingBatchHelper = require('../support/helpers/billing-batch.helper.js') -const BillingBatchModel = require('../../app/models/billing-batch.model.js') -const DatabaseHelper = require('../support/helpers/database.helper.js') -const LicenceHelper = require('../support/helpers/licence.helper.js') -const LicenceModel = require('../../app/models/licence.model.js') -const RegionHelper = require('../support/helpers/region.helper.js') +const BillingBatchHelper = require('../../support/helpers/water/billing-batch.helper.js') +const BillingBatchModel = require('../../../app/models/water/billing-batch.model.js') +const DatabaseHelper = require('../../support/helpers/database.helper.js') +const LicenceHelper = require('../../support/helpers/water/licence.helper.js') +const LicenceModel = require('../../../app/models/water/licence.model.js') +const RegionHelper = require('../../support/helpers/water/region.helper.js') // Thing under test -const RegionModel = require('../../app/models/region.model.js') +const RegionModel = require('../../../app/models/water/region.model.js') describe('Region model', () => { let testRecord From 471f342e10e07453ad7d3e44f551384ebe9f38af Mon Sep 17 00:00:00 2001 From: Alan Cruikshanks Date: Thu, 5 Jan 2023 17:10:08 +0000 Subject: [PATCH 5/9] Update references With all the movement we need to update all our references. --- app/services/charge-module-token.service.js | 1 + .../create-billing-batch-event.service.js | 2 +- .../create-billing-batch.service.js | 2 +- .../fetch-charge-versions.service.js | 2 +- .../supplementary-billing/fetch-licences.service.js | 2 +- .../supplementary-billing/fetch-region.service.js | 2 +- .../create-billing-batch-event.presenter.test.js | 6 +++--- .../create-billing-batch-event.service.test.js | 8 ++++---- .../create-billing-batch.service.test.js | 6 +++--- .../fetch-charge-versions.service.test.js | 10 +++++----- .../fetch-licences.service.test.js | 4 ++-- .../supplementary-billing/fetch-region.service.test.js | 2 +- .../initiate-billing-batch.service.test.js | 6 +++--- 13 files changed, 27 insertions(+), 26 deletions(-) diff --git a/app/services/charge-module-token.service.js b/app/services/charge-module-token.service.js index 3cd1cb00fe..d4548bf727 100644 --- a/app/services/charge-module-token.service.js +++ b/app/services/charge-module-token.service.js @@ -10,6 +10,7 @@ const RequestLib = require('../lib/request.lib.js') const servicesConfig = require('../../config/services.config.js') async function go () { + console.log(`--> ${servicesConfig.chargingModule.token.url}`) const url = new URL('/oauth2/token', servicesConfig.chargingModule.token.url) const result = await RequestLib.post(url.href, _options()) diff --git a/app/services/supplementary-billing/create-billing-batch-event.service.js b/app/services/supplementary-billing/create-billing-batch-event.service.js index e832718897..02a73bfa86 100644 --- a/app/services/supplementary-billing/create-billing-batch-event.service.js +++ b/app/services/supplementary-billing/create-billing-batch-event.service.js @@ -6,7 +6,7 @@ */ const CreateBillingBatchEventPresenter = require('../../presenters/supplementary-billing/create-billing-batch-event.presenter.js') -const EventModel = require('../../models/event.model.js') +const EventModel = require('../../models/water/event.model.js') /** * Create an event for when a new bill run is initialised diff --git a/app/services/supplementary-billing/create-billing-batch.service.js b/app/services/supplementary-billing/create-billing-batch.service.js index 909c60118b..3dd90723a7 100644 --- a/app/services/supplementary-billing/create-billing-batch.service.js +++ b/app/services/supplementary-billing/create-billing-batch.service.js @@ -5,7 +5,7 @@ * @module CreateBillingBatchService */ -const BillingBatchModel = require('../../models/billing-batch.model.js') +const BillingBatchModel = require('../../models/water/billing-batch.model.js') /** * Create a new billing batch diff --git a/app/services/supplementary-billing/fetch-charge-versions.service.js b/app/services/supplementary-billing/fetch-charge-versions.service.js index eb77c6c364..e78ed8bfc8 100644 --- a/app/services/supplementary-billing/fetch-charge-versions.service.js +++ b/app/services/supplementary-billing/fetch-charge-versions.service.js @@ -5,7 +5,7 @@ * @module FetchChargeVersionsService */ -const ChargeVersion = require('../../models/charge-version.model.js') +const ChargeVersion = require('../../models/water/charge-version.model.js') /** * Fetch all SROC charge versions linked to licences flagged for supplementary billing that are in the period being diff --git a/app/services/supplementary-billing/fetch-licences.service.js b/app/services/supplementary-billing/fetch-licences.service.js index cd5dd8c3dd..9a64c0ee42 100644 --- a/app/services/supplementary-billing/fetch-licences.service.js +++ b/app/services/supplementary-billing/fetch-licences.service.js @@ -5,7 +5,7 @@ * @module FetchLicencesService */ -const LicenceModel = require('../../models/licence.model.js') +const LicenceModel = require('../../models/water/licence.model.js') /** * Fetches licences flagged for supplementary billing that are linked to the selected region diff --git a/app/services/supplementary-billing/fetch-region.service.js b/app/services/supplementary-billing/fetch-region.service.js index d08762d097..0af8a81f95 100644 --- a/app/services/supplementary-billing/fetch-region.service.js +++ b/app/services/supplementary-billing/fetch-region.service.js @@ -5,7 +5,7 @@ * @module FetchRegionService */ -const RegionModel = require('../../models/region.model.js') +const RegionModel = require('../../models/water/region.model.js') /** * Fetches the region with the matching NALD Region ID diff --git a/test/presenters/supplementary-billing/create-billing-batch-event.presenter.test.js b/test/presenters/supplementary-billing/create-billing-batch-event.presenter.test.js index 08be6787cd..224938cf2b 100644 --- a/test/presenters/supplementary-billing/create-billing-batch-event.presenter.test.js +++ b/test/presenters/supplementary-billing/create-billing-batch-event.presenter.test.js @@ -8,10 +8,10 @@ const { describe, it, beforeEach } = exports.lab = Lab.script() const { expect } = Code // Test helpers -const BillingBatchHelper = require('../../support/helpers/billing-batch.helper.js') -const BillingBatchModel = require('../../../app/models/billing-batch.model.js') +const BillingBatchHelper = require('../../support/helpers/water/billing-batch.helper.js') +const BillingBatchModel = require('../../../app/models/water/billing-batch.model.js') const DatabaseHelper = require('../../support/helpers/database.helper.js') -const RegionHelper = require('../../support/helpers/region.helper.js') +const RegionHelper = require('../../support/helpers/water/region.helper.js') // Thing under test const CreateBillingBatchEventPresenter = require('../../../app/presenters/supplementary-billing/create-billing-batch-event.presenter.js') diff --git a/test/services/supplementary-billing/create-billing-batch-event.service.test.js b/test/services/supplementary-billing/create-billing-batch-event.service.test.js index 55e7962244..ea60429f47 100644 --- a/test/services/supplementary-billing/create-billing-batch-event.service.test.js +++ b/test/services/supplementary-billing/create-billing-batch-event.service.test.js @@ -8,11 +8,11 @@ const { describe, it, beforeEach } = exports.lab = Lab.script() const { expect } = Code // Test helpers -const BillingBatchHelper = require('../../support/helpers/billing-batch.helper.js') -const BillingBatchModel = require('../../../app/models/billing-batch.model.js') +const BillingBatchHelper = require('../../support/helpers/water/billing-batch.helper.js') +const BillingBatchModel = require('../../../app/models/water/billing-batch.model.js') const DatabaseHelper = require('../../support/helpers/database.helper.js') -const EventModel = require('../../../app/models/event.model.js') -const RegionHelper = require('../../support/helpers/region.helper.js') +const EventModel = require('../../../app/models/water/event.model.js') +const RegionHelper = require('../../support/helpers/water/region.helper.js') // Thing under test const CreateBillingBatchEventService = require('../../../app/services/supplementary-billing/create-billing-batch-event.service.js') diff --git a/test/services/supplementary-billing/create-billing-batch.service.test.js b/test/services/supplementary-billing/create-billing-batch.service.test.js index e1c1759b7b..a296d26d69 100644 --- a/test/services/supplementary-billing/create-billing-batch.service.test.js +++ b/test/services/supplementary-billing/create-billing-batch.service.test.js @@ -8,10 +8,10 @@ const { describe, it, beforeEach } = exports.lab = Lab.script() const { expect } = Code // Test helpers -const BillingBatchModel = require('../../../app/models/billing-batch.model.js') +const BillingBatchModel = require('../../../app/models/water/billing-batch.model.js') const DatabaseHelper = require('../../support/helpers/database.helper.js') -const RegionHelper = require('../../support/helpers/region.helper.js') -const RegionModel = require('../../../app/models/region.model.js') +const RegionHelper = require('../../support/helpers/water/region.helper.js') +const RegionModel = require('../../../app/models/water/region.model.js') // Thing under test const CreateBillingBatchService = require('../../../app/services/supplementary-billing/create-billing-batch.service.js') diff --git a/test/services/supplementary-billing/fetch-charge-versions.service.test.js b/test/services/supplementary-billing/fetch-charge-versions.service.test.js index 95e48a2238..dd50c6d88d 100644 --- a/test/services/supplementary-billing/fetch-charge-versions.service.test.js +++ b/test/services/supplementary-billing/fetch-charge-versions.service.test.js @@ -8,12 +8,12 @@ const { describe, it, beforeEach } = exports.lab = Lab.script() const { expect } = Code // Test helpers -const BillingChargeCategoryHelper = require('../../support/helpers/billing-charge-category.helper.js') -const ChargeElementHelper = require('../../support/helpers/charge-element.helper.js') -const ChargePurposeHelper = require('../../support/helpers/charge-purpose.helper.js') -const ChargeVersionHelper = require('../../support/helpers/charge-version.helper.js') +const BillingChargeCategoryHelper = require('../../support/helpers/water/billing-charge-category.helper.js') +const ChargeElementHelper = require('../../support/helpers/water/charge-element.helper.js') +const ChargePurposeHelper = require('../../support/helpers/water/charge-purpose.helper.js') +const ChargeVersionHelper = require('../../support/helpers/water/charge-version.helper.js') const DatabaseHelper = require('../../support/helpers/database.helper.js') -const LicenceHelper = require('../../support/helpers/licence.helper.js') +const LicenceHelper = require('../../support/helpers/water/licence.helper.js') // Thing under test const FetchChargeVersionsService = require('../../../app/services/supplementary-billing/fetch-charge-versions.service.js') diff --git a/test/services/supplementary-billing/fetch-licences.service.test.js b/test/services/supplementary-billing/fetch-licences.service.test.js index 85dff5b2b0..3a97ba3c25 100644 --- a/test/services/supplementary-billing/fetch-licences.service.test.js +++ b/test/services/supplementary-billing/fetch-licences.service.test.js @@ -8,9 +8,9 @@ const { describe, it, beforeEach } = exports.lab = Lab.script() const { expect } = Code // Test helpers -const ChargeVersionHelper = require('../../support/helpers/charge-version.helper.js') +const ChargeVersionHelper = require('../../support/helpers/water/charge-version.helper.js') const DatabaseHelper = require('../../support/helpers/database.helper.js') -const LicenceHelper = require('../../support/helpers/licence.helper.js') +const LicenceHelper = require('../../support/helpers/water/licence.helper.js') // Thing under test const FetchLicencesService = require('../../../app/services/supplementary-billing/fetch-licences.service.js') diff --git a/test/services/supplementary-billing/fetch-region.service.test.js b/test/services/supplementary-billing/fetch-region.service.test.js index 9cb3e11e8c..0de893ce05 100644 --- a/test/services/supplementary-billing/fetch-region.service.test.js +++ b/test/services/supplementary-billing/fetch-region.service.test.js @@ -9,7 +9,7 @@ const { expect } = Code // Test helpers const DatabaseHelper = require('../../support/helpers/database.helper.js') -const RegionHelper = require('../../support/helpers/region.helper.js') +const RegionHelper = require('../../support/helpers/water/region.helper.js') // Thing under test const FetchRegionService = require('../../../app/services/supplementary-billing/fetch-region.service.js') diff --git a/test/services/supplementary-billing/initiate-billing-batch.service.test.js b/test/services/supplementary-billing/initiate-billing-batch.service.test.js index 5f249342b6..d2989806a6 100644 --- a/test/services/supplementary-billing/initiate-billing-batch.service.test.js +++ b/test/services/supplementary-billing/initiate-billing-batch.service.test.js @@ -9,10 +9,10 @@ const { describe, it, beforeEach, afterEach } = exports.lab = Lab.script() const { expect } = Code // Test helpers -const BillingBatchModel = require('../../../app/models/billing-batch.model.js') +const BillingBatchModel = require('../../../app/models/water/billing-batch.model.js') const DatabaseHelper = require('../../support/helpers/database.helper.js') -const EventModel = require('../../../app/models/event.model.js') -const RegionHelper = require('../../support/helpers/region.helper.js') +const EventModel = require('../../../app/models/water/event.model.js') +const RegionHelper = require('../../support/helpers/water/region.helper.js') // Things we need to stub const BillingPeriodService = require('../../../app/services/supplementary-billing/billing-period.service.js') From 22bd349b6bb634d5d537c71afbee025fd65a55df Mon Sep 17 00:00:00 2001 From: Alan Cruikshanks Date: Thu, 5 Jan 2023 18:01:29 +0000 Subject: [PATCH 6/9] Restructure the base models MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This means adding 2 new base models, one extending from the other with `BaseModel` as the root parent. This also means we can move out of BaseModel functionality we only added to support working with the legacy service and it's various schemas. When we get to add our own models, they won't need to inherit this cruft. Whilst doing this we were able to make some changes to the whole declaring the schema name solution. The original was made in 2016, so for example `RelatedQueryBuilder` is defunct (should have spotted that before 🤦). And as we only need this in the `LegacyBaseModel` we no longer assign our custom QueryBuilder to Objection's root Model `QueryBuilder` property. Finally, we added some documentation around all this so if we ever have to look at it again we'll have a clue what what it's all about. --- app/models/base.model.js | 38 ++++---------- app/models/legacy-base.model.js | 77 ++++++++++++++++++++++++++++ app/models/water/water-base.model.js | 16 ++++++ 3 files changed, 104 insertions(+), 27 deletions(-) create mode 100644 app/models/legacy-base.model.js create mode 100644 app/models/water/water-base.model.js diff --git a/app/models/base.model.js b/app/models/base.model.js index d1b03b5e22..893b5c1c48 100644 --- a/app/models/base.model.js +++ b/app/models/base.model.js @@ -5,7 +5,7 @@ * @module BaseModel */ -const { Model, QueryBuilder } = require('objection') +const { Model } = require('objection') const { db } = require('../../db/db.js') @@ -16,42 +16,26 @@ Model.knex(db) class BaseModel extends Model { /** - * An objective property we override to tell it where to search for models for relationships + * Array of paths to search for models used in relationships * - * When setting a relationship in a model we have to provide a reference to the related model. As we need to set the - * relationship on both sides this leads to + * This is an objective property we override. When setting a relationship in a model we have to provide a reference + * to the related model. As we need to set the relationship on both sides this leads to * {@link https://vincit.github.io/objection.js/guide/relations.html#require-loops|require-loops}. We can avoid this * by having the model tell Objection where to search for models for relationships. In the relationship declaration we * can then just use a string value * * ``` - * // ... - * relation: Model.ManyToManyRelation, - modelClass: 'charge_version.model', - // ... - ``` - - We don't want to do this in every model so set it in the `BaseModel` as Objection recommends. + * // ... + * relation: Model.ManyToManyRelation, + * modelClass: 'charge_version.model', + * // ... + * ``` + * + * We don't want to do this in every model so set it in the `BaseModel` as Objection recommends. */ static get modelPaths () { return [__dirname] } - - static get defaultSchema () { - return 'water' - } } -class DefaultSchemaQueryBuilder extends QueryBuilder { - constructor (modelClass) { - super(modelClass) - if (modelClass.defaultSchema) { - this.withSchema(modelClass.defaultSchema) - } - } -} - -Model.QueryBuilder = DefaultSchemaQueryBuilder -Model.RelatedQueryBuilder = DefaultSchemaQueryBuilder - module.exports = BaseModel diff --git a/app/models/legacy-base.model.js b/app/models/legacy-base.model.js new file mode 100644 index 0000000000..64853a6c94 --- /dev/null +++ b/app/models/legacy-base.model.js @@ -0,0 +1,77 @@ +'use strict' + +/** + * Base class for all models based on tables in the legacy schemas + * @module LegacyBaseModel + */ + +const { QueryBuilder } = require('objection') +const path = require('path') + +const BaseModel = require('./base.model.js') + +class LegacyBaseModel extends BaseModel { + /** + * Array of paths to search for models used in relationships + * + * > See `modelPaths()` in `BaseModel` for more details on this getter + * + * We override the one provided in `BaseModel` to include our legacy folders. + * + * @returns {Array} array of paths to search for related models + */ + static get modelPaths () { + const currentPath = __dirname + return [ + currentPath, + path.join(currentPath, 'water') + ] + } + + /** + * Returns a custom `QueryBuilder` which supports declaring the schema to use when connecting to the DB + * + * See `schema()` for further details. + * + * @returns {Object} a custom Objection `QueryBuilder` + */ + static get QueryBuilder () { + return SchemaQueryBuilder + } + + /** + * Name of the database schema a model belongs to + * + * All the legacy repos talk to the same PostgreSQL DB server but split their data using + * {@link https://www.postgresql.org/docs/current/ddl-schemas.html schemas}. Objection.js however assumes you are + * using the **public** schema which is the default in PostgreSQL if you don't specify one. + * + * So, when Objection is working with our legacy models it needs to know what schemas they belong to. There is no + * out-of-the-box support for specifying this. But the maintainer behind Objection.js suggested this solution in + * {@link https://github.com/Vincit/objection.js/issues/85#issuecomment-185183032 an issue} (which we've tweaked + * slightly). + * + * You extend Objection's QueryBuilder (see `SchemaQueryBuilder`) and call Knex's `withSchema()` within it (Knex + * _does_ understand schemas). It expects the Model generating the query to have a custom getter `schema` which + * returns the schema name. You then override the getter `QueryBuilder` in your model and return your + * {@link https://vincit.github.io/objection.js/recipes/custom-query-builder.html custom QueryBuilder}. This is then + * used to build any queries, for example, `MyModel.query.find()` ensuring the schema name is declared and our data + * layer knows where to find the data. + * + * > In this base model model we throw an exception to ensure any child classes override this getter. + * + * @returns {string} the schema name, for example, 'water' + */ + static get schema () { + throw new Error('defaultSchema() not implemented in child class') + } +} + +class SchemaQueryBuilder extends QueryBuilder { + constructor (modelClass) { + super(modelClass) + this.withSchema(modelClass.schema) + } +} + +module.exports = LegacyBaseModel diff --git a/app/models/water/water-base.model.js b/app/models/water/water-base.model.js new file mode 100644 index 0000000000..ed429e8eeb --- /dev/null +++ b/app/models/water/water-base.model.js @@ -0,0 +1,16 @@ +'use strict' + +/** + * Base class for all models based on the legacy 'water' schema + * @module WaterBaseModel + */ + +const LegacyBaseModel = require('../legacy-base.model.js') + +class WaterBaseModel extends LegacyBaseModel { + static get schema () { + return 'water' + } +} + +module.exports = WaterBaseModel From 8686abea3d304a261c05647629d3398a4a7f59d5 Mon Sep 17 00:00:00 2001 From: Alan Cruikshanks Date: Thu, 5 Jan 2023 18:07:40 +0000 Subject: [PATCH 7/9] Update the models to use new base model --- app/models/water/billing-batch.model.js | 4 ++-- app/models/water/billing-charge-category.model.js | 4 ++-- app/models/water/charge-element.model.js | 4 ++-- app/models/water/charge-purpose.model.js | 4 ++-- app/models/water/charge-version.model.js | 4 ++-- app/models/water/event.model.js | 4 ++-- app/models/water/licence.model.js | 4 ++-- app/models/water/region.model.js | 4 ++-- 8 files changed, 16 insertions(+), 16 deletions(-) diff --git a/app/models/water/billing-batch.model.js b/app/models/water/billing-batch.model.js index e5fde201f2..8ca92c907f 100644 --- a/app/models/water/billing-batch.model.js +++ b/app/models/water/billing-batch.model.js @@ -7,9 +7,9 @@ const { Model } = require('objection') -const BaseModel = require('../base.model.js') +const WaterBaseModel = require('./water-base.model.js') -class BillingBatchModel extends BaseModel { +class BillingBatchModel extends WaterBaseModel { static get tableName () { return 'billingBatches' } diff --git a/app/models/water/billing-charge-category.model.js b/app/models/water/billing-charge-category.model.js index 7f713ed1b8..40a245fc1b 100644 --- a/app/models/water/billing-charge-category.model.js +++ b/app/models/water/billing-charge-category.model.js @@ -7,9 +7,9 @@ const { Model } = require('objection') -const BaseModel = require('../base.model.js') +const WaterBaseModel = require('./water-base.model.js') -class BillingChargeCategoryModel extends BaseModel { +class BillingChargeCategoryModel extends WaterBaseModel { static get tableName () { return 'billingChargeCategories' } diff --git a/app/models/water/charge-element.model.js b/app/models/water/charge-element.model.js index 1855c0c5af..0605eaa618 100644 --- a/app/models/water/charge-element.model.js +++ b/app/models/water/charge-element.model.js @@ -7,9 +7,9 @@ const { Model } = require('objection') -const BaseModel = require('../base.model.js') +const WaterBaseModel = require('./water-base.model.js') -class ChargeElementModel extends BaseModel { +class ChargeElementModel extends WaterBaseModel { static get tableName () { return 'chargeElements' } diff --git a/app/models/water/charge-purpose.model.js b/app/models/water/charge-purpose.model.js index 1a712eb4c8..850e55525a 100644 --- a/app/models/water/charge-purpose.model.js +++ b/app/models/water/charge-purpose.model.js @@ -7,9 +7,9 @@ const { Model } = require('objection') -const BaseModel = require('../base.model.js') +const WaterBaseModel = require('./water-base.model.js') -class ChargePurposeModel extends BaseModel { +class ChargePurposeModel extends WaterBaseModel { static get tableName () { return 'chargePurposes' } diff --git a/app/models/water/charge-version.model.js b/app/models/water/charge-version.model.js index 4b1b053606..d2698e4cff 100644 --- a/app/models/water/charge-version.model.js +++ b/app/models/water/charge-version.model.js @@ -7,9 +7,9 @@ const { Model } = require('objection') -const BaseModel = require('../base.model.js') +const WaterBaseModel = require('./water-base.model.js') -class ChargeVersionModel extends BaseModel { +class ChargeVersionModel extends WaterBaseModel { static get tableName () { return 'chargeVersions' } diff --git a/app/models/water/event.model.js b/app/models/water/event.model.js index de46608532..6161743e68 100644 --- a/app/models/water/event.model.js +++ b/app/models/water/event.model.js @@ -5,9 +5,9 @@ * @module EventModel */ -const BaseModel = require('../base.model.js') +const WaterBaseModel = require('./water-base.model.js') -class EventModel extends BaseModel { +class EventModel extends WaterBaseModel { static get tableName () { return 'events' } diff --git a/app/models/water/licence.model.js b/app/models/water/licence.model.js index e98d40cd18..4413ea6837 100644 --- a/app/models/water/licence.model.js +++ b/app/models/water/licence.model.js @@ -7,9 +7,9 @@ const { Model } = require('objection') -const BaseModel = require('../base.model.js') +const WaterBaseModel = require('./water-base.model.js') -class LicenceModel extends BaseModel { +class LicenceModel extends WaterBaseModel { static get tableName () { return 'licences' } diff --git a/app/models/water/region.model.js b/app/models/water/region.model.js index 45123d7492..a6727d453a 100644 --- a/app/models/water/region.model.js +++ b/app/models/water/region.model.js @@ -7,9 +7,9 @@ const { Model } = require('objection') -const BaseModel = require('../base.model.js') +const WaterBaseModel = require('./water-base.model.js') -class RegionModel extends BaseModel { +class RegionModel extends WaterBaseModel { static get tableName () { return 'regions' } From 96226bde00cdeace9f79a0b1078731225410d306 Mon Sep 17 00:00:00 2001 From: Alan Cruikshanks Date: Thu, 5 Jan 2023 18:08:08 +0000 Subject: [PATCH 8/9] Add a test to ensure 'not implemented' is tested --- test/models/legacy-base.model.test.js | 35 +++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 test/models/legacy-base.model.test.js diff --git a/test/models/legacy-base.model.test.js b/test/models/legacy-base.model.test.js new file mode 100644 index 0000000000..7125a00d94 --- /dev/null +++ b/test/models/legacy-base.model.test.js @@ -0,0 +1,35 @@ +'use strict' + +// Test framework dependencies +const Lab = require('@hapi/lab') +const Code = require('@hapi/code') + +const { describe, it } = exports.lab = Lab.script() +const { expect } = Code + +// Thing under test +const LegacyBaseModel = require('../../app/models/legacy-base.model.js') + +describe('Legacy Base model', () => { + describe('.schema()', () => { + describe('when the getter is not overridden', () => { + class BadModel extends LegacyBaseModel {} + + it('throws an error when called', () => { + expect(() => BadModel.query()).to.throw() + }) + }) + + describe('when the getter is overridden', () => { + class GoodModel extends LegacyBaseModel { + static get schema () { + return 'water' + } + } + + it('does not throw an error when called', () => { + expect(() => GoodModel.query()).not.to.throw() + }) + }) + }) +}) From 808dbfe5bbdd1441401bae834ae9979a1bb1e9dd Mon Sep 17 00:00:00 2001 From: Alan Cruikshanks Date: Fri, 6 Jan 2023 08:32:18 +0000 Subject: [PATCH 9/9] Remove errant console.log --- app/services/charge-module-token.service.js | 1 - 1 file changed, 1 deletion(-) diff --git a/app/services/charge-module-token.service.js b/app/services/charge-module-token.service.js index d4548bf727..3cd1cb00fe 100644 --- a/app/services/charge-module-token.service.js +++ b/app/services/charge-module-token.service.js @@ -10,7 +10,6 @@ const RequestLib = require('../lib/request.lib.js') const servicesConfig = require('../../config/services.config.js') async function go () { - console.log(`--> ${servicesConfig.chargingModule.token.url}`) const url = new URL('/oauth2/token', servicesConfig.chargingModule.token.url) const result = await RequestLib.post(url.href, _options())