Skip to content

Commit

Permalink
fix: (iac) last error does not override previous
Browse files Browse the repository at this point in the history
  • Loading branch information
Ilianna Papastefanou committed May 23, 2022
1 parent e082575 commit d9e3449
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 5 deletions.
3 changes: 1 addition & 2 deletions src/cli/commands/test/iac/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ export default async function(
};

res = results;
iacScanFailures = failures ? failures : [];
iacScanFailures = [...iacScanFailures, ...(failures || [])];
iacIgnoredIssuesCount += ignoreCount;
} catch (error) {
res = formatTestError(error);
Expand All @@ -141,7 +141,6 @@ export default async function(
// Not all test results are arrays in order to be backwards compatible
// with scripts that use a callback with test. Coerce results/errors to be arrays
// and add the result options to each to be displayed
// TODO: Similarly to above, do we actually need to convert this to an array?
const resArray: any[] = Array.isArray(res) ? res : [res];

for (let i = 0; i < resArray.length; i++) {
Expand Down
5 changes: 2 additions & 3 deletions test/jest/acceptance/iac/test-directory.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,9 +104,8 @@ describe('Directory scan', () => {
);
//directory scan shows relative path to cwd in output
expect(stdout).toContain('Testing sg_open_ssh.tf');
//TODO: currently the failures show only for the second path->cloudformation so this will fail:
// expect(stdout).toContain('Testing sg_open_ssh_invalid_hcl2.tf');
// expect(stdout).toContain('Failed to parse Terraform file');
expect(stdout).toContain('Testing sg_open_ssh_invalid_hcl2.tf');
expect(stdout).toContain('Failed to parse Terraform file');
expect(stdout).toContain('Testing aurora-valid.yml');
expect(stdout).toContain('Testing invalid-cfn.yml');
expect(stdout).toContain('Failed to parse YAML file');
Expand Down

0 comments on commit d9e3449

Please sign in to comment.