Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix legacy requests for /heath/info page #860

Merged
merged 4 commits into from
Mar 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/services/health/info.service.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ async function _getLegacyAppData () {
]

for (const service of services) {
const result = await LegacyRequest.get(service.serviceName, healthInfoPath, false)
const result = await LegacyRequest.get(service.serviceName, healthInfoPath, null, false)

if (result.succeeded) {
service.version = result.response.body.version
Expand Down
32 changes: 16 additions & 16 deletions test/services/health/info.service.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ const BaseRequest = require('../../../app/requests/base.request.js')

// Thing under test
// Normally we'd set this to `= require('../../app/services/health/info.service')`. But to control how
// `child_process.exec()` behaves in the service, after it's been promisfied we have to use proxyquire.
// `child_process.exec()` behaves in the service, after it's been promisified we have to use proxyquire.
let InfoService // = require('../../app/services/health/info.service')

describe('Info service', () => {
Expand Down Expand Up @@ -72,15 +72,15 @@ describe('Info service', () => {

// These requests will remain unchanged throughout the tests. We do alter the ones to the AddressFacade and the
// water-api (foreground-service) though, which is why they are defined separately in each test.
legacyRequestStub.withArgs('background', 'health/info', false).resolves(goodRequestResults.app)
legacyRequestStub.withArgs('reporting', 'health/info', false).resolves(goodRequestResults.app)
legacyRequestStub.withArgs('import', 'health/info', false).resolves(goodRequestResults.app)
legacyRequestStub.withArgs('crm', 'health/info', false).resolves(goodRequestResults.app)
legacyRequestStub.withArgs('external', 'health/info', false).resolves(goodRequestResults.app)
legacyRequestStub.withArgs('internal', 'health/info', false).resolves(goodRequestResults.app)
legacyRequestStub.withArgs('idm', 'health/info', false).resolves(goodRequestResults.app)
legacyRequestStub.withArgs('permits', 'health/info', false).resolves(goodRequestResults.app)
legacyRequestStub.withArgs('returns', 'health/info', false).resolves(goodRequestResults.app)
legacyRequestStub.withArgs('background', 'health/info', null, false).resolves(goodRequestResults.app)
legacyRequestStub.withArgs('reporting', 'health/info', null, false).resolves(goodRequestResults.app)
legacyRequestStub.withArgs('import', 'health/info', null, false).resolves(goodRequestResults.app)
legacyRequestStub.withArgs('crm', 'health/info', null, false).resolves(goodRequestResults.app)
legacyRequestStub.withArgs('external', 'health/info', null, false).resolves(goodRequestResults.app)
legacyRequestStub.withArgs('internal', 'health/info', null, false).resolves(goodRequestResults.app)
legacyRequestStub.withArgs('idm', 'health/info', null, false).resolves(goodRequestResults.app)
legacyRequestStub.withArgs('permits', 'health/info', null, false).resolves(goodRequestResults.app)
legacyRequestStub.withArgs('returns', 'health/info', null, false).resolves(goodRequestResults.app)

chargingModuleRequestStub
.withArgs('status')
Expand All @@ -100,7 +100,7 @@ describe('Info service', () => {
baseRequestStub
.withArgs(`${servicesConfig.addressFacade.url}/address-service/hola`)
.resolves(goodRequestResults.addressFacade)
legacyRequestStub.withArgs('water', 'health/info', false).resolves(goodRequestResults.app)
legacyRequestStub.withArgs('water', 'health/info', null, false).resolves(goodRequestResults.app)

// Unfortunately, this convoluted test setup is the only way we've managed to stub how the promisified version of
// `child-process.exec()` behaves in the module under test.
Expand Down Expand Up @@ -162,7 +162,7 @@ describe('Info service', () => {
baseRequestStub
.withArgs(`${servicesConfig.addressFacade.url}/address-service/hola`)
.resolves(goodRequestResults.addressFacade)
legacyRequestStub.withArgs('water', 'health/info', false).resolves(goodRequestResults.app)
legacyRequestStub.withArgs('water', 'health/info', null, false).resolves(goodRequestResults.app)

const execStub = Sinon
.stub()
Expand Down Expand Up @@ -208,7 +208,7 @@ describe('Info service', () => {
baseRequestStub
.withArgs(`${servicesConfig.addressFacade.url}/address-service/hola`)
.resolves(goodRequestResults.addressFacade)
legacyRequestStub.withArgs('water', 'health/info', false).resolves(goodRequestResults.app)
legacyRequestStub.withArgs('water', 'health/info', null, false).resolves(goodRequestResults.app)
})

describe('is not running', () => {
Expand Down Expand Up @@ -277,7 +277,7 @@ describe('Info service', () => {
baseRequestStub
.withArgs(`${servicesConfig.addressFacade.url}/address-service/hola`)
.resolves(goodRequestResults.addressFacade)
legacyRequestStub.withArgs('water', 'health/info', false).resolves(goodRequestResults.app)
legacyRequestStub.withArgs('water', 'health/info', null, false).resolves(goodRequestResults.app)

const execStub = Sinon
.stub()
Expand Down Expand Up @@ -356,7 +356,7 @@ describe('Info service', () => {
baseRequestStub
.withArgs(`${servicesConfig.addressFacade.url}/address-service/hola`)
.resolves(badResult)
legacyRequestStub.withArgs('water', 'health/info', false).resolves(badResult)
legacyRequestStub.withArgs('water', 'health/info', null, false).resolves(badResult)
})

it('handles the error and still returns a result for the other services', async () => {
Expand All @@ -383,7 +383,7 @@ describe('Info service', () => {
baseRequestStub
.withArgs(`${servicesConfig.addressFacade.url}/address-service/hola`)
.resolves(badResult)
legacyRequestStub.withArgs('water', 'health/info', false).resolves(badResult)
legacyRequestStub.withArgs('water', 'health/info', null, false).resolves(badResult)
})

it('handles the error and still returns a result for the other services', async () => {
Expand Down
Loading