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

printresults:chore - add tests to cover output and Sonarqube output type #760

Merged
merged 1 commit into from
Nov 11, 2021

Conversation

matheusalcantarazup
Copy link
Contributor

@matheusalcantarazup matheusalcantarazup commented Nov 9, 2021

This commit add new tests to cover Sonarqube output type and add asserts
to check if what was printed is correctly.

The tests was changed to use table testings approach to make more easily
to add a new testcase.

The PrintResults implementation was improved too. Basically a new
io.Writer field was added to customize where we will write outputs. The
default constructor will always write to Stdout, but on tests we use a
custom BufferString to write.

This commit also make some improvements on code organization and private
method names.

Updates #718

Signed-off-by: Matheus Alcantara [email protected]

- What I did

- How to verify it

- Description for the changelog

@matheusalcantarazup matheusalcantarazup changed the title printresults:chore: add tests to cover errors and Sonarqube output printresults:chore: add tests to cover output and Sonarqube output type Nov 9, 2021
@matheusalcantarazup matheusalcantarazup force-pushed the tests-printressults branch 4 times, most recently from 9b86bd2 to 87dce39 Compare November 9, 2021 17:59
This commit add new tests to cover Sonarqube output type and add asserts
to check if what was printed is correctly.

The tests was changed to use table testings approach to make more easily
to add a new testcase.

The PrintResults implementation was improved too. Basically a new
io.Writer field was added to customize where we will write outputs. The
default constructor will always write to Stdout, but on tests we use a
custom BufferString to write.

This commit also make some improvements on code organization and private
method names.

Updates #718

Signed-off-by: Matheus Alcantara <[email protected]>
@wiliansilvazup wiliansilvazup changed the title printresults:chore: add tests to cover output and Sonarqube output type printresults:chore - add tests to cover output and Sonarqube output type Nov 10, 2021
@matheusalcantarazup matheusalcantarazup merged commit 20e7581 into main Nov 11, 2021
@matheusalcantarazup matheusalcantarazup deleted the tests-printressults branch November 11, 2021 12:28
matheusalcantarazup added a commit that referenced this pull request Dec 1, 2021
On #760 we made an improvement on `getDefaultTotalVulnBySeverity` which
reuse the map returned from `getDefaultCountBySeverity` as a value for
all keys on the default map of vulnerability severities, but since a map
in Go is a pointer we was using the same map to all keys and when we
were going to count vulnerabilities by severity, we would update the
same pointer for all the keys in that map, which caused inconsistent
and duplicated values in the final result.

This commit revert this change and call pr.getDefaultCountBySeverity for
all keys on this map.

Signed-off-by: Matheus Alcantara <[email protected]>
matheusalcantarazup added a commit that referenced this pull request Dec 1, 2021
On #760 we made an improvement on `getDefaultTotalVulnBySeverity` which
reuse the map returned from `getDefaultCountBySeverity` as a value for
all keys on the default map of vulnerability severities, but since a map
in Go is a pointer we was using the same map to all keys and when we
were going to count vulnerabilities by severity, we would update the
same pointer for all the keys in that map, which caused inconsistent
and duplicated values in the final result.

This commit revert this change and call pr.getDefaultCountBySeverity for
all keys on this map.

The test case was copied and paste with this bug and was also updated.

Signed-off-by: Matheus Alcantara <[email protected]>
matheusalcantarazup added a commit that referenced this pull request Dec 1, 2021
On #760 we made an improvement on `getDefaultTotalVulnBySeverity` which
reuse the map returned from `getDefaultCountBySeverity` as a value for
all keys on the default map of vulnerability severities, but since a map
in Go is a pointer we was using the same map to all keys and when we
were going to count vulnerabilities by severity, we would update the
same pointer for all the keys in that map, which caused inconsistent
and duplicated values in the final result.

This commit revert this change and call pr.getDefaultCountBySeverity for
all keys on this map.

The test case was copied and paste with this bug and was also updated.

Signed-off-by: Matheus Alcantara <[email protected]>
matheusalcantarazup added a commit that referenced this pull request Dec 2, 2021
On #760 we made an improvement on `getDefaultTotalVulnBySeverity` which
reuse the map returned from `getDefaultCountBySeverity` as a value for
all keys on the default map of vulnerability severities, but since a map
in Go is a pointer we was using the same map to all keys and when we
were going to count vulnerabilities by severity, we would update the
same pointer for all the keys in that map, which caused inconsistent
and duplicated values in the final result.

This commit revert this change and call pr.getDefaultCountBySeverity for
all keys on this map.

The test case was copied and paste with this bug and was also updated.

Signed-off-by: Matheus Alcantara <[email protected]>
(cherry picked from commit f71ca15)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants