Implement pagination on Organization Outside Collaborators Client GetAll() method (#1650)

* Reimplement ApiOptions overloads

* Unskip pagination tests and set page sizes correctly
This commit is contained in:
Ryan Gribble
2017-08-10 06:07:18 +10:00
committed by GitHub
parent 635b42d735
commit b0ff506ab3
8 changed files with 535 additions and 10 deletions
@@ -48,6 +48,54 @@ namespace Octokit.Tests.Integration.Clients
}
}
[IntegrationTest]
public async Task ReturnsCorrectCountOfOutsideCollaboratorsWithoutStart()
{
var repoName = Helper.MakeNameWithTimestamp("public-repo");
using (var context = await _gitHub.CreateRepositoryContext(Helper.Organization, new NewRepository(repoName)))
{
await _gitHub.Repository.Collaborator.Add(context.RepositoryOwner, context.RepositoryName, _fixtureCollaborator);
var options = new ApiOptions
{
PageSize = 1,
PageCount = 1
};
var outsideCollaborators = await _gitHub.Organization
.OutsideCollaborator
.GetAll(Helper.Organization, options);
Assert.NotNull(outsideCollaborators);
Assert.Equal(1, outsideCollaborators.Count);
}
}
[IntegrationTest]
public async Task ReturnsCorrectCountOfOutsideCollaboratorsWithStart()
{
var repoName = Helper.MakeNameWithTimestamp("public-repo");
using (var context = await _gitHub.CreateRepositoryContext(Helper.Organization, new NewRepository(repoName)))
{
await _gitHub.Repository.Collaborator.Add(context.RepositoryOwner, context.RepositoryName, _fixtureCollaborator);
await _gitHub.Repository.Collaborator.Add(context.RepositoryOwner, context.RepositoryName, "alfhenrik");
var options = new ApiOptions
{
PageSize = 1,
PageCount = 1,
StartPage = 1
};
var outsideCollaborators = await _gitHub.Organization
.OutsideCollaborator
.GetAll(Helper.Organization, options);
Assert.NotNull(outsideCollaborators);
Assert.Equal(1, outsideCollaborators.Count);
}
}
[IntegrationTest]
public async Task ReturnsCorrectCountOfOutsideCollaboratorsWithAllFilter()
{
@@ -66,6 +114,67 @@ namespace Octokit.Tests.Integration.Clients
}
}
[IntegrationTest]
public async Task ReturnsCorrectCountOfOutsideCollaboratorsWithAllFilterAndApiOptions()
{
var repoName = Helper.MakeNameWithTimestamp("public-repo");
using (var context = await _gitHub.CreateRepositoryContext(Helper.Organization, new NewRepository(repoName)))
{
await _gitHub.Repository.Collaborator.Add(context.RepositoryOwner, context.RepositoryName, _fixtureCollaborator);
await _gitHub.Repository.Collaborator.Add(context.RepositoryOwner, context.RepositoryName, "alfhenrik");
var options = new ApiOptions
{
PageCount = 1,
PageSize = 1
};
var outsideCollaborators = await _gitHub.Organization
.OutsideCollaborator
.GetAll(Helper.Organization, OrganizationMembersFilter.All, options);
Assert.NotNull(outsideCollaborators);
Assert.Equal(1, outsideCollaborators.Count);
}
}
[IntegrationTest]
public async Task ReturnsCorrectCountOfOutsideCollaboratorsWithAllFilterWithStart()
{
var repoName = Helper.MakeNameWithTimestamp("public-repo");
using (var context = await _gitHub.CreateRepositoryContext(Helper.Organization, new NewRepository(repoName)))
{
await _gitHub.Repository.Collaborator.Add(context.RepositoryOwner, context.RepositoryName, _fixtureCollaborator);
await _gitHub.Repository.Collaborator.Add(context.RepositoryOwner, context.RepositoryName, "alfhenrik");
var firstPageOptions = new ApiOptions
{
PageCount = 1,
PageSize = 1,
StartPage = 1
};
var firstPageOfOutsideCollaborators = await _gitHub.Organization
.OutsideCollaborator
.GetAll(Helper.Organization, OrganizationMembersFilter.All, firstPageOptions);
var secondPageOptions = new ApiOptions
{
PageCount = 1,
PageSize = 1,
StartPage = 2
};
var secondPageOfOutsideCollaborators = await _gitHub.Organization
.OutsideCollaborator
.GetAll(Helper.Organization, OrganizationMembersFilter.All, secondPageOptions);
Assert.Equal(1, firstPageOfOutsideCollaborators.Count);
Assert.Equal(1, secondPageOfOutsideCollaborators.Count);
Assert.NotEqual(firstPageOfOutsideCollaborators[0].Login, secondPageOfOutsideCollaborators[0].Login);
}
}
[IntegrationTest]
public async Task ReturnsCorrectCountOfOutsideCollaboratorsWithTwoFactorFilter()
{
@@ -84,6 +193,31 @@ namespace Octokit.Tests.Integration.Clients
Assert.Equal(_fixtureCollaborator, outsideCollaborators[0].Login);
}
}
[IntegrationTest]
public async Task ReturnsCorrectCountOfOutsideCollaboratorsWithTwoFactorFilterAndApiOptions()
{
var repoName = Helper.MakeNameWithTimestamp("public-repo");
using (var context = await _gitHub.CreateRepositoryContext(Helper.Organization, new NewRepository(repoName)))
{
await _gitHub.Repository.Collaborator.Add(context.RepositoryOwner, context.RepositoryName, _fixtureCollaborator);
await _gitHub.Repository.Collaborator.Add(context.RepositoryOwner, context.RepositoryName, "alfhenrik");
var options = new ApiOptions
{
PageCount = 1,
PageSize = 1
};
var outsideCollaborators = await _gitHub.Organization
.OutsideCollaborator
.GetAll(Helper.Organization, OrganizationMembersFilter.TwoFactorAuthenticationDisabled, options);
Assert.NotNull(outsideCollaborators);
Assert.Equal(1, outsideCollaborators.Count);
Assert.Equal(_fixtureCollaborator, outsideCollaborators[0].Login);
}
}
}
public class TheDeleteMethod
@@ -46,6 +46,52 @@ namespace Octokit.Tests.Integration.Reactive
}
}
[IntegrationTest]
public async Task ReturnsCorrectCountOfOutsideCollaboratorsWithoutStart()
{
var repoName = Helper.MakeNameWithTimestamp("public-repo");
using (var context = await _gitHub.CreateRepositoryContext(Helper.Organization, new NewRepository(repoName)))
{
await _gitHub.Repository.Collaborator.Add(context.RepositoryOwner, context.RepositoryName, _fixtureCollaborator);
var options = new ApiOptions
{
PageSize = 1,
PageCount = 1
};
var outsideCollaborators = await _client
.GetAll(Helper.Organization, options).ToList();
Assert.NotNull(outsideCollaborators);
Assert.Equal(1, outsideCollaborators.Count);
}
}
[IntegrationTest]
public async Task ReturnsCorrectCountOfOutsideCollaboratorsWithStart()
{
var repoName = Helper.MakeNameWithTimestamp("public-repo");
using (var context = await _gitHub.CreateRepositoryContext(Helper.Organization, new NewRepository(repoName)))
{
await _gitHub.Repository.Collaborator.Add(context.RepositoryOwner, context.RepositoryName, _fixtureCollaborator);
await _gitHub.Repository.Collaborator.Add(context.RepositoryOwner, context.RepositoryName, "alfhenrik");
var options = new ApiOptions
{
PageSize = 1,
PageCount = 1,
StartPage = 1
};
var outsideCollaborators = await _client
.GetAll(Helper.Organization, options).ToList();
Assert.NotNull(outsideCollaborators);
Assert.Equal(1, outsideCollaborators.Count);
}
}
[IntegrationTest]
public async Task ReturnsCorrectCountOfOutsideCollaboratorsWithAllFilter()
{
@@ -63,6 +109,64 @@ namespace Octokit.Tests.Integration.Reactive
}
}
[IntegrationTest]
public async Task ReturnsCorrectCountOfOutsideCollaboratorsWithAllFilterAndApiOptions()
{
var repoName = Helper.MakeNameWithTimestamp("public-repo");
using (var context = await _gitHub.CreateRepositoryContext(Helper.Organization, new NewRepository(repoName)))
{
await _gitHub.Repository.Collaborator.Add(context.RepositoryOwner, context.RepositoryName, _fixtureCollaborator);
await _gitHub.Repository.Collaborator.Add(context.RepositoryOwner, context.RepositoryName, "alfhenrik");
var options = new ApiOptions
{
PageCount = 1,
PageSize = 1
};
var outsideCollaborators = await _client
.GetAll(Helper.Organization, OrganizationMembersFilter.All, options).ToList();
Assert.NotNull(outsideCollaborators);
Assert.Equal(1, outsideCollaborators.Count);
}
}
[IntegrationTest]
public async Task ReturnsCorrectCountOfOutsideCollaboratorsWithAllFilterWithStart()
{
var repoName = Helper.MakeNameWithTimestamp("public-repo");
using (var context = await _gitHub.CreateRepositoryContext(Helper.Organization, new NewRepository(repoName)))
{
await _gitHub.Repository.Collaborator.Add(context.RepositoryOwner, context.RepositoryName, _fixtureCollaborator);
await _gitHub.Repository.Collaborator.Add(context.RepositoryOwner, context.RepositoryName, "alfhenrik");
var firstPageOptions = new ApiOptions
{
PageCount = 1,
PageSize = 1,
StartPage = 1
};
var firstPageOfOutsideCollaborators = await _client
.GetAll(Helper.Organization, OrganizationMembersFilter.All, firstPageOptions).ToList();
var secondPageOptions = new ApiOptions
{
PageCount = 1,
PageSize = 1,
StartPage = 2
};
var secondPageOfOutsideCollaborators = await _client
.GetAll(Helper.Organization, OrganizationMembersFilter.All, secondPageOptions).ToList();
Assert.Equal(1, firstPageOfOutsideCollaborators.Count);
Assert.Equal(1, secondPageOfOutsideCollaborators.Count);
Assert.NotEqual(firstPageOfOutsideCollaborators[0].Login, secondPageOfOutsideCollaborators[0].Login);
}
}
[IntegrationTest]
public async Task ReturnsCorrectCountOfOutsideCollaboratorsWithTwoFactorFilter()
{
@@ -80,6 +184,30 @@ namespace Octokit.Tests.Integration.Reactive
Assert.Equal("alfhenrik-test-2", outsideCollaborators[0].Login);
}
}
[IntegrationTest]
public async Task ReturnsCorrectCountOfOutsideCollaboratorsWithTwoFactorFilterAndApiOptions()
{
var repoName = Helper.MakeNameWithTimestamp("public-repo");
using (var context = await _gitHub.CreateRepositoryContext(Helper.Organization, new NewRepository(repoName)))
{
await _gitHub.Repository.Collaborator.Add(context.RepositoryOwner, context.RepositoryName, _fixtureCollaborator);
await _gitHub.Repository.Collaborator.Add(context.RepositoryOwner, context.RepositoryName, "alfhenrik");
var options = new ApiOptions
{
PageCount = 1,
PageSize = 1
};
var outsideCollaborators = await _client
.GetAll(Helper.Organization, OrganizationMembersFilter.TwoFactorAuthenticationDisabled, options).ToList();
Assert.NotNull(outsideCollaborators);
Assert.Equal(1, outsideCollaborators.Count);
Assert.Equal("alfhenrik-test-2", outsideCollaborators[0].Login);
}
}
}
public class TheDeleteMethod