Skip to content

Commit

Permalink
Fix #443 - ACNA-1239 (#456)
Browse files Browse the repository at this point in the history
* look at deployedRuntimeEntities.actions to see what was actually deployed

* better mock result of deployActions
  • Loading branch information
purplecabbage authored Aug 5, 2021
1 parent de8f8e3 commit 46238bb
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 8 deletions.
15 changes: 12 additions & 3 deletions src/commands/app/deploy.js
Original file line number Diff line number Diff line change
Expand Up @@ -120,9 +120,18 @@ class Deploy extends BuildCommand {
try {
const script = await runScript(config.hooks['deploy-actions'])
if (!script) {
deployedRuntimeEntities = { ...await rtLib.deployActions(config, { filterEntities }, onProgress) }
deployedRuntimeEntities = await rtLib.deployActions(config, { filterEntities }, onProgress)
}

if (deployedRuntimeEntities.actions && deployedRuntimeEntities.actions.length > 0) {
spinner.succeed(chalk.green(`Deployed ${deployedRuntimeEntities.actions.length} action(s) for '${name}'`))
} else {
if (script) {
spinner.fail(chalk.green(`build-action skipped by hook '${name}'`))
} else {
spinner.fail(chalk.green(`No actions deployed for '${name}'`))
}
}
spinner.succeed(chalk.green(message))
} catch (err) {
spinner.fail(chalk.green(message))
throw err
Expand Down Expand Up @@ -152,7 +161,7 @@ class Deploy extends BuildCommand {
}

// log deployed resources
if (deployedRuntimeEntities.actions) {
if (deployedRuntimeEntities.actions && deployedRuntimeEntities.actions.length > 0) {
this.log(chalk.blue(chalk.bold('Your deployed actions:')))
deployedRuntimeEntities.actions.forEach(a => {
this.log(chalk.blue(chalk.bold(` -> ${a.url || a.name} `)))
Expand Down
10 changes: 5 additions & 5 deletions test/commands/app/deploy.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ describe('run', () => {
command.getLibConsoleCLI = jest.fn(() => mockLibConsoleCLI)
command.getFullConfig = jest.fn()

mockRuntimeLib.deployActions.mockResolvedValue({})
mockRuntimeLib.deployActions.mockResolvedValue({ actions: [] })
mockWebLib.bundle.mockResolvedValue({ run: mockBundleFunc })
})

Expand All @@ -213,7 +213,6 @@ describe('run', () => {
command.getAppExtConfigs.mockReturnValueOnce(createAppConfig(command.appConfig))

await command.run()
// expect(command.error).toHaveBeenCalledWith(0)
expect(command.error).toHaveBeenCalledTimes(0)
expect(command.buildOneExt).toHaveBeenCalledTimes(1)
expect(mockRuntimeLib.deployActions).toHaveBeenCalledTimes(1)
Expand Down Expand Up @@ -515,7 +514,7 @@ describe('run', () => {
test('should fail if scripts.deployWeb fails', async () => {
command.getAppExtConfigs.mockReturnValueOnce(createAppConfig(command.appConfig))
const error = new Error('mock failure')
mockRuntimeLib.deployActions.mockResolvedValue('ok')
mockRuntimeLib.deployActions.mockResolvedValue({ actions: [] })
mockWebLib.deployWeb.mockRejectedValue(error)

await expect(command.run()).rejects.toEqual(error)
Expand All @@ -524,7 +523,7 @@ describe('run', () => {

test('spinner should be called for progress logs on deployWeb call , with verbose', async () => {
command.getAppExtConfigs.mockReturnValueOnce(createAppConfig(command.appConfig))
mockRuntimeLib.deployActions.mockResolvedValue('ok')
mockRuntimeLib.deployActions.mockResolvedValue({ actions: [] })
mockWebLib.deployWeb.mockImplementation(async (config, log) => {
log('progress log')
return 'ok'
Expand All @@ -540,7 +539,7 @@ describe('run', () => {
const appConfig = createAppConfig(command.appConfig)
command.getAppExtConfigs.mockReturnValueOnce(appConfig)

mockRuntimeLib.deployActions.mockResolvedValue('ok')
mockRuntimeLib.deployActions.mockResolvedValue({ actions: [] })
mockWebLib.deployWeb.mockImplementation(async (config, log) => {
log('progress log')
return 'ok'
Expand Down Expand Up @@ -629,6 +628,7 @@ describe('run', () => {
.mockResolvedValueOnce(childProcess) // deploy-static (uses hook)
.mockResolvedValueOnce(noScriptFound) // post-app-deploy

mockRuntimeLib.deployActions.mockResolvedValue({ actions: [] })
await command.run()
expect(mockRuntimeLib.deployActions).toHaveBeenCalledTimes(0)
expect(mockWebLib.deployWeb).toHaveBeenCalledTimes(0)
Expand Down

0 comments on commit 46238bb

Please sign in to comment.