mirror of
https://github.com/zoriya/octokit.net.git
synced 2026-06-07 20:30:41 +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
@@ -4,6 +4,7 @@ using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Reactive.Threading.Tasks;
|
||||
using System.Threading.Tasks;
|
||||
using Octokit.Reactive.Internal;
|
||||
using Xunit;
|
||||
|
||||
namespace Octokit.Tests.Reactive
|
||||
@@ -306,5 +307,55 @@ namespace Octokit.Tests.Reactive
|
||||
await Assert.ThrowsAsync<ArgumentException>(() => client.Conceal("org", "").ToTask());
|
||||
}
|
||||
}
|
||||
|
||||
public class TheGetAllPendingInvitationsMethod
|
||||
{
|
||||
[Fact]
|
||||
public void RequestsTheCorrectUrl()
|
||||
{
|
||||
var gitHubClient = Substitute.For<IGitHubClient>();
|
||||
var client = new ObservableOrganizationMembersClient(gitHubClient);
|
||||
|
||||
client.GetAllPendingInvitations("org");
|
||||
|
||||
gitHubClient.Connection.Received().GetAndFlattenAllPages<OrganizationMembershipInvitation>(
|
||||
Arg.Is<Uri>(u => u.ToString() == "orgs/org/invitations"),
|
||||
Args.EmptyDictionary,
|
||||
"application/vnd.github.korra-preview+json");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void RequestsTheCorrectUrlWithStart()
|
||||
{
|
||||
var gitHubClient = Substitute.For<IGitHubClient>();
|
||||
var client = new ObservableOrganizationMembersClient(gitHubClient);
|
||||
var options = new ApiOptions
|
||||
{
|
||||
PageCount = 1,
|
||||
PageSize = 1,
|
||||
StartPage = 1
|
||||
};
|
||||
|
||||
client.GetAllPendingInvitations("org", options);
|
||||
|
||||
gitHubClient.Connection.Received().GetAndFlattenAllPages<OrganizationMembershipInvitation>(
|
||||
Arg.Is<Uri>(u => u.ToString() == "orgs/org/invitations"),
|
||||
Arg.Is<Dictionary<string, string>>(d => d.Count == 2),
|
||||
"application/vnd.github.korra-preview+json");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task EnsuresNonNullArguments()
|
||||
{
|
||||
var client = new ObservableOrganizationMembersClient(Substitute.For<IGitHubClient>());
|
||||
|
||||
await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetAllPendingInvitations(null).ToTask());
|
||||
await Assert.ThrowsAsync<ArgumentException>(() => client.GetAllPendingInvitations("").ToTask());
|
||||
|
||||
await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetAllPendingInvitations(null, ApiOptions.None).ToTask());
|
||||
await Assert.ThrowsAsync<ArgumentException>(() => client.GetAllPendingInvitations("", ApiOptions.None).ToTask());
|
||||
await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetAllPendingInvitations("org", null).ToTask());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user