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

test: add tests for gitMergeRequests #169

Merged
merged 4 commits into from
Oct 26, 2023
Merged

Conversation

nsshaddox
Copy link
Contributor

I could use some insight on practical test cases. I have hit all the lines of code but the tests are not very significant.

@nsshaddox nsshaddox requested a review from a team as a code owner October 25, 2023 20:11
@github-actions github-actions bot added the go label Oct 25, 2023
@codecov
Copy link

codecov bot commented Oct 25, 2023

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (6f6f9db) 33.93% compared to head (6ae68ef) 36.31%.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #169      +/-   ##
==========================================
+ Coverage   33.93%   36.31%   +2.37%     
==========================================
  Files           9        9              
  Lines         716      716              
==========================================
+ Hits          243      260      +17     
+ Misses        463      446      -17     
  Partials       10       10              

see 1 file with indirect coverage changes

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

{
desc: "valid mergeRequestData",
client: &mockClient{
maxPages: 1,
Copy link
Contributor

Choose a reason for hiding this comment

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

You could have another test for multiple pages and no pages

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good idea. Thank!

assert.Equal(t, len(ch), 1)
} else {
assert.Equal(t, len(ch), 1)
for data := range ch {
Copy link
Contributor

@rhoofard rhoofard Oct 25, 2023

Choose a reason for hiding this comment

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

Should move this out of the if else block since it should be tested even if theres an error which should have a total mr count of 0. Also there will only ever be a channel size of one so maybe theres a better way to do this than a for loop?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I needed something in the if statement in case I wanted to add something but since there is nothing to add, I'll move it out. Good call out.

} else {
assert.Equal(t, len(ch), 1)
for data := range ch {
assert.Equal(t, len(data), tc.expectedNodeLen)
Copy link
Contributor

Choose a reason for hiding this comment

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

This should also be renamed to total mr count (idk how to suggest a code change)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Changed to expectedMergeRequestLength

I think this is what you mean.

@nsshaddox nsshaddox linked an issue Oct 25, 2023 that may be closed by this pull request
@nsshaddox nsshaddox merged commit 4928d69 into main Oct 26, 2023
10 checks passed
@nsshaddox nsshaddox deleted the gitlab-test-getmergerequests branch October 26, 2023 20:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add gitlab_scraper_test.go for gitlab scraper's gitlab_scraper.go
2 participants