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

added corner cases for comments.go in astbuilder package #3134

Merged
merged 7 commits into from
Jul 17, 2023

Conversation

khareyash05
Copy link
Contributor

What this PR does / why we need it:
Increase test coverage of astbuillder/comments.go to add corner cases of empty comments and text width =0

If applicable:

  • this PR contains documentation
  • this PR contains tests

Signed-off-by: Yash Khare <yash2010118@akgec.ac.in>
Comment on lines 52 to 54
if c.comment == "" {
continue
}
Copy link
Member

Choose a reason for hiding this comment

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

All this does is to suppress the new test case - it's never run at all, so it adds nothing to the coverage.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Will update the same

Comment on lines 81 to 83
if c.width == 0 {
continue
}
Copy link
Member

Choose a reason for hiding this comment

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

Ditto here; all you're doing is skipping the test if the passed width is zero.

Signed-off-by: Yash Khare <yash2010118@akgec.ac.in>
@@ -70,6 +71,8 @@ func TestWordWrap(t *testing.T) {
{"this is a simple line of text", 16, []string{"this is a simple ", "line of text"}},
{"this is a simple line of text", 20, []string{"this is a simple ", "line of text"}},
{"this is a simple line of text", 21, []string{"this is a simple line ", "of text"}},
{"", 0, []string{}},
{"this is a sample text", 0, []string{}},
Copy link
Member

Choose a reason for hiding this comment

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

We should never throw away content like this - if someone inadvertently passes a width of 0 we want to return the content anyway. For consistency with existing behaviour when width is 1, this should be:

Suggested change
{"this is a sample text", 0, []string{}},
{"this is a sample text", 0, []string{"this ", "is ", "a ", "sample ", "text"}},

Copy link
Member

@theunrepentantgeek theunrepentantgeek left a comment

Choose a reason for hiding this comment

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

Adding coverage of edge cases is valuable, but don't lose sight of the context the methods are used within.

khareyash05 and others added 3 commits July 13, 2023 09:05
@theunrepentantgeek
Copy link
Member

/ok-to-test sha=7ee6c95

@codecov-commenter
Copy link

codecov-commenter commented Jul 16, 2023

Codecov Report

Merging #3134 (e3be922) into main (e4e6b74) will decrease coverage by 0.03%.
The diff coverage is 64.04%.

@@            Coverage Diff             @@
##             main    #3134      +/-   ##
==========================================
- Coverage   54.17%   54.15%   -0.03%     
==========================================
  Files        1418     1419       +1     
  Lines      608163   608072      -91     
==========================================
- Hits       329486   329311     -175     
- Misses     224662   224764     +102     
+ Partials    54015    53997      -18     
Impacted Files Coverage Δ
...01101/network_security_group_spec_arm_types_gen.go 33.33% <ø> (ø)
.../v1api20201101/network_security_group_types_gen.go 59.35% <ø> (-0.47%) ⬇️
...ecurity_groups_security_rule_spec_arm_types_gen.go 33.33% <ø> (ø)
...0201101storage/network_security_group_types_gen.go 55.17% <ø> (ø)
...01101/network_security_group_spec_arm_types_gen.go 33.33% <ø> (ø)
...v1beta20201101/network_security_group_types_gen.go 58.41% <ø> (+1.26%) ⬆️
...ecurity_groups_security_rule_spec_arm_types_gen.go 33.33% <ø> (ø)
...0201101storage/network_security_group_types_gen.go 52.98% <ø> (-1.65%) ⬇️
v2/internal/controllers/controller_resources.go 80.00% <ø> (-2.36%) ⬇️
...ilers/arm/azure_generic_arm_reconciler_instance.go 66.50% <ø> (-2.38%) ⬇️
... and 12 more

... and 46 files with indirect coverage changes

@theunrepentantgeek
Copy link
Member

/ok-to-test sha=e3be922

@theunrepentantgeek
Copy link
Member

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@theunrepentantgeek theunrepentantgeek merged commit e748005 into Azure:main Jul 17, 2023
8 checks passed
@theunrepentantgeek
Copy link
Member

Thanks @khareyash05.

@theunrepentantgeek theunrepentantgeek added this to the v2.2.0 milestone Jul 24, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Development

Successfully merging this pull request may close these issues.

None yet

3 participants