-
Couldn't load subscription status.
- Fork 0
Add a pagination test for IssueList #2
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
Conversation
|
bd097a9 As expected, added test is failed. See the result of GitHub Actions. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great catch! Both the fix and the test look great 💖
api/queries_issue.go
Outdated
| loop: | ||
| for { | ||
| variables["limit"] = pageLimit | ||
| var response struct { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To avoid redeclaring this struct completely in every loop iteration, do you think your approach would also work if this struct was defined as a type outside of a loop, and response was created inside a loop here as an instance of that type?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for your review.
I think my approach works even if the type (struct) is defined outside the loop.
After response is defined in each loop and the data is parsed into response, issues share the array referenced by the response until the next loop, but when moving to the next loop, response goes out of scope and destructed. Therefore, the array is only referenced by issues, not the same array in the next loop.
So it's okay to declare the type (struct) outside the loop. It seems that the loop code is easier to read.
api/queries_issue_test.go
Outdated
| }, | ||
| } | ||
| for _, tt := range tests { | ||
| t.Run(tt.name, func(t *testing.T) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this need to be a table-based test since it only contains a single test case?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not necessary. I'll fix this.
|
I made a Pull Request to original repository cli#2190 |
Added test is expeceted to fail by data overwriting.