mirror of
https://github.com/zoriya/octokit.net.git
synced 2026-06-08 12:42:32 +00:00
List pending organization / team invitations (#1640)
* Add methods for listing pending organization invites * Add unit/integration tests * Add methods for getting all pending invites for a team * Add unit/integration tests * 🔥 whitespace 🔥 * Move new enum to it's own correct file and location * Invite(s) -> Invitation(s) * Add helper functions for adding invitations and cleaning the invitations up at the end of the test * Add methods with ApiOptions * Fix helper methods for adding/removing invitations * Forgot to actually pass in the ApiOptions to the API call * Add tests for new ApiOptions methods * tweak integration tests * Update outside collaborator tests to use [OrganizationTest] attribute for consistency * Update test accounts used * use octokitnet-test2 account now it has 2FA turned on
This commit is contained in:
committed by
Ryan Gribble
parent
b0ff506ab3
commit
7c170213fd
@@ -1,5 +1,6 @@
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Octokit.Tests.Integration.Helpers;
|
||||
using Xunit;
|
||||
|
||||
namespace Octokit.Tests.Integration.Clients
|
||||
@@ -17,7 +18,7 @@ namespace Octokit.Tests.Integration.Clients
|
||||
_organizationFixture = "octokit";
|
||||
}
|
||||
|
||||
[IntegrationTest]
|
||||
[OrganizationTest]
|
||||
public async Task ReturnsMembers()
|
||||
{
|
||||
var members = await
|
||||
@@ -25,7 +26,7 @@ namespace Octokit.Tests.Integration.Clients
|
||||
Assert.NotEmpty(members);
|
||||
}
|
||||
|
||||
[IntegrationTest]
|
||||
[OrganizationTest]
|
||||
public async Task ReturnsCorrectCountOfMembersWithoutStart()
|
||||
{
|
||||
var options = new ApiOptions
|
||||
@@ -39,7 +40,7 @@ namespace Octokit.Tests.Integration.Clients
|
||||
Assert.Equal(1, members.Count);
|
||||
}
|
||||
|
||||
[IntegrationTest]
|
||||
[OrganizationTest]
|
||||
public async Task ReturnsCorrectCountOfMembersWithStart()
|
||||
{
|
||||
var options = new ApiOptions
|
||||
@@ -54,7 +55,7 @@ namespace Octokit.Tests.Integration.Clients
|
||||
Assert.Equal(1, members.Count);
|
||||
}
|
||||
|
||||
[IntegrationTest]
|
||||
[OrganizationTest]
|
||||
public async Task ReturnsDistinctMembersBasedOnStartPage()
|
||||
{
|
||||
var startOptions = new ApiOptions
|
||||
@@ -119,5 +120,91 @@ namespace Octokit.Tests.Integration.Clients
|
||||
Assert.True(membersWithNo2FA.Count <= memberCount);
|
||||
}
|
||||
}
|
||||
|
||||
public class TheGetAllPendingInvitationsMethod
|
||||
{
|
||||
readonly IGitHubClient _gitHub;
|
||||
|
||||
public TheGetAllPendingInvitationsMethod()
|
||||
{
|
||||
_gitHub = Helper.GetAuthenticatedClient();
|
||||
}
|
||||
|
||||
[OrganizationTest]
|
||||
public async Task ReturnsNoPendingInvitations()
|
||||
{
|
||||
var pendingInvitations = await _gitHub.Organization.Member.GetAllPendingInvitations(Helper.Organization);
|
||||
Assert.NotNull(pendingInvitations);
|
||||
Assert.Empty(pendingInvitations);
|
||||
}
|
||||
|
||||
[OrganizationTest]
|
||||
public async Task ReturnsPendingInvitations()
|
||||
{
|
||||
using (var teamContext = await _gitHub.CreateTeamContext(Helper.Organization, new NewTeam(Helper.MakeNameWithTimestamp("team"))))
|
||||
{
|
||||
teamContext.InviteMember("octokitnet-test1");
|
||||
teamContext.InviteMember("octokitnet-test2");
|
||||
|
||||
var pendingInvitations = await _gitHub.Organization.Member.GetAllPendingInvitations(Helper.Organization);
|
||||
Assert.NotEmpty(pendingInvitations);
|
||||
Assert.Equal(2, pendingInvitations.Count);
|
||||
}
|
||||
}
|
||||
|
||||
[OrganizationTest]
|
||||
public async Task ReturnsCorrectCountOfPendingInvitationsWithoutStart()
|
||||
{
|
||||
using (var teamContext = await _gitHub.CreateTeamContext(Helper.Organization, new NewTeam(Helper.MakeNameWithTimestamp("team"))))
|
||||
{
|
||||
teamContext.InviteMember("octokitnet-test1");
|
||||
teamContext.InviteMember("octokitnet-test2");
|
||||
|
||||
var options = new ApiOptions
|
||||
{
|
||||
PageCount = 1,
|
||||
PageSize = 1
|
||||
};
|
||||
|
||||
var pendingInvitations = await _gitHub.Organization.Member.GetAllPendingInvitations(Helper.Organization, options);
|
||||
Assert.NotEmpty(pendingInvitations);
|
||||
Assert.Equal(1, pendingInvitations.Count);
|
||||
}
|
||||
}
|
||||
|
||||
[OrganizationTest]
|
||||
public async Task ReturnsCorrectCountOfPendingInvitationsWithStart()
|
||||
{
|
||||
using (var teamContext = await _gitHub.CreateTeamContext(Helper.Organization, new NewTeam(Helper.MakeNameWithTimestamp("team"))))
|
||||
{
|
||||
teamContext.InviteMember("octokitnet-test1");
|
||||
teamContext.InviteMember("octokitnet-test2");
|
||||
|
||||
var firstPageOptions = new ApiOptions
|
||||
{
|
||||
PageCount = 1,
|
||||
PageSize = 1,
|
||||
StartPage = 1
|
||||
};
|
||||
|
||||
var firstPagePendingInvitations = await _gitHub.Organization.Member.GetAllPendingInvitations(Helper.Organization, firstPageOptions);
|
||||
Assert.NotEmpty(firstPagePendingInvitations);
|
||||
Assert.Equal(1, firstPagePendingInvitations.Count);
|
||||
|
||||
var secondPageOptions = new ApiOptions
|
||||
{
|
||||
PageCount = 1,
|
||||
PageSize = 1,
|
||||
StartPage = 2
|
||||
};
|
||||
|
||||
var secondPagePendingInvitations = await _gitHub.Organization.Member.GetAllPendingInvitations(Helper.Organization, secondPageOptions);
|
||||
Assert.NotEmpty(secondPagePendingInvitations);
|
||||
Assert.Equal(1, secondPagePendingInvitations.Count);
|
||||
|
||||
Assert.NotEqual(firstPagePendingInvitations[0].Login, secondPagePendingInvitations[0].Login);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user