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

Not fatal #88

Merged
merged 3 commits into from
Oct 17, 2023
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
11 changes: 5 additions & 6 deletions src/hooks/utils/hook-utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -174,12 +174,11 @@ async function getAllRegistrationsForWorkspace (eventsSDK, project) {
*/
async function deployRegistration ({ appConfig: { events, project } }, expectedDeliveryType, hookType, forceEventsFlag) {
if (!project) {
throw new Error(
`No project found, skipping event registration in ${hookType} hook`)
aioLogger.debug(`No project found, skipping event registration in ${hookType} hook`)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should we do the same for undeployRegistration method also

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was aiming to fix an error that is happening in CICD, I do not expect they are using undeploy, but yes, that likely needs to be fixed also.

return
}
if (!events) {
aioLogger.debug(
`No events to register, skipping event registration in ${hookType} hook`)
aioLogger.debug(`No events to register, skipping event registration in ${hookType} hook`)
return
}
const eventsSDK = await initEventsSdk(project)
Expand Down Expand Up @@ -237,8 +236,8 @@ async function deployRegistration ({ appConfig: { events, project } }, expectedD
*/
async function undeployRegistration ({ appConfig: { events, project } }) {
if (!project) {
throw new Error(
'No project found, skipping deletion of event registrations')
aioLogger.debug('No project with events to delete, skipping deletion of event registrations')
return
}
if (!events) {
aioLogger.debug('No events to delete, skipping deletion of event registrations')
Expand Down
10 changes: 2 additions & 8 deletions test/hooks/post-deploy-event-reg.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,16 +41,10 @@ describe('post deploy event registration hook interfaces', () => {
expect(typeof hook).toBe('function')
})

test('command-error', async () => {
test('no project should return without error', async () => {
const hook = require('../../src/hooks/post-deploy-event-reg')
expect(typeof hook).toBe('function')
await expect(hook({ appConfig: {} })).rejects.toThrow(new Error('No project found, skipping event registration in post-deploy-event-reg hook'))
})

test('no project error', async () => {
const hook = require('../../src/hooks/post-deploy-event-reg')
expect(typeof hook).toBe('function')
await expect(hook({ appConfig: {} })).rejects.toThrow(new Error('No project found, skipping event registration in post-deploy-event-reg hook'))
await expect(hook({ appConfig: {} })).resolves.not.toThrow()
})

test('no events should return without error', async () => {
Expand Down
4 changes: 2 additions & 2 deletions test/hooks/pre-undeploy-event-reg.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,10 @@ describe('pre undeploy event registration hook interfaces', () => {
expect(typeof hook).toBe('function')
})

test('no project error', async () => {
test('no project should return without error', async () => {
const hook = require('../../src/hooks/pre-undeploy-event-reg')
expect(typeof hook).toBe('function')
await expect(hook({ appConfig: {} })).rejects.toThrow(new Error('No project found, skipping deletion of event registrations'))
await expect(hook({ appConfig: {} })).resolves.not.toThrow()
})

test('no events should return without error', async () => {
Expand Down
Loading