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

Add Page property to control pagination. Add asynchronous support for GetCommits, GetCommit, and GetCommitDiff #754

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

ingshak
Copy link
Contributor

@ingshak ingshak commented Sep 9, 2024

Added a Page property to control pagination, helping to avoid unnecessary data fetches.
Introduced asynchronous support for the following methods: GetCommits, GetCommit, and GetCommitDiff.

@ingshak ingshak requested a review from a team as a code owner September 9, 2024 16:24
@ingshak ingshak requested review from louis-z and removed request for a team September 9, 2024 16:24
Comment on lines +145 to +148
using var context = await RepositoryClientTestsContext.CreateAsync(commitCount: 5);

var defaultBranch = context.Project.DefaultBranch;
var since = DateTime.UtcNow;
Copy link
Member

Choose a reason for hiding this comment

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

Unless I'm missing something, the test here will collect no commit whatsoever. To truly test this, you should create a few (e.g. 5) commits over a small period of time, say one every 200 ms, and then list commits from the creation time of one of the middle commits.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This function is similar to GetCommitsSince. The common code has been refactored and is now shared between both functions. Should I also update GetCommitsSince to align with these changes? Also, I agree I need to at least add a new test to ensure it is thoroughly tested.

// Assert
var lastRequestQueryString = context.Context.LastRequest.RequestUri.Query;

Assert.That(lastRequestQueryString, Does.Contain($"since={expectedSinceValue}"));
Copy link
Member

Choose a reason for hiding this comment

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

This assertion has little value. What's more relevant is that we do get only the commits from since...

// Assert
var lastRequestQueryString = context.Context.LastRequest.RequestUri.Query;

Assert.That(lastRequestQueryString, Does.Not.Contain("since="));
Copy link
Member

Choose a reason for hiding this comment

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

Again, I'm not sure this assertion is relevant... I would probably remove that test altogether.

// Arrange
using var context = await RepositoryClientTestsContext.CreateAsync(commitCount: 5);

var defaultBranch = context.Project.DefaultBranch;
Copy link
Member

Choose a reason for hiding this comment

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

Again, I would stagger the creation commits over a short period of time and validate that specifying until works as expected.

@@ -170,6 +293,178 @@ public async Task GetCommitsDoesntIncludeUntilWhenNotSpecified()
Assert.That(lastRequestQueryString, Does.Not.Contain("until="));
}

[Test]
[NGitLabRetry]
public async Task GetCommitsDoesntIncludeUntilWhenNotSpecifiedAsync()
Copy link
Member

Choose a reason for hiding this comment

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

Remove test?

var lastRequestQueryString = context.Context.LastRequest.RequestUri.Query;

NameValueCollection queryParameters = HttpUtility.ParseQueryString(lastRequestQueryString);
Assert.That(queryParameters, Does.Not.Contain("page"));
Copy link
Member

Choose a reason for hiding this comment

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

I would prefer that the behavior, from a user's perspective, be tested. With a 5-commit setup and per_page=2 you could test what happens when page

  • is not set
  • is < 3
  • is >= 3


[Test]
[NGitLabRetry]
public async Task GetCommitsDoesntIncludePageWhenNotSpecifiedAsync()
Copy link
Member

Choose a reason for hiding this comment

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

Remove test?

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.

2 participants