diff --git a/Octokit.Reactive/Clients/IObservableTeamsClient.cs b/Octokit.Reactive/Clients/IObservableTeamsClient.cs
index 0ca0a385bf..908960b903 100644
--- a/Octokit.Reactive/Clients/IObservableTeamsClient.cs
+++ b/Octokit.Reactive/Clients/IObservableTeamsClient.cs
@@ -171,6 +171,20 @@ public interface IObservableTeamsClient
/// if the repository was added to the team; otherwise.
IObservable AddRepository(int id, string organization, string repoName);
+ ///
+ /// Adds a to a .
+ ///
+ /// The team identifier.
+ /// Org to associate the repo with.
+ /// Name of the repo.
+ /// The permission to grant the team on this repository.
+ /// Thrown if you attempt to add a repository to a team that is not owned by the organization.
+ ///
+ /// See the API documentation for more information.
+ ///
+ /// if the repository was added to the team; otherwise.
+ IObservable AddRepository(int id, string organization, string repoName, RepositoryPermissionRequest permission);
+
///
/// Gets whether or not the given repository is managed by the given team.
///
diff --git a/Octokit.Reactive/Clients/ObservableTeamsClient.cs b/Octokit.Reactive/Clients/ObservableTeamsClient.cs
index be061f3cbd..0cb63575d7 100644
--- a/Octokit.Reactive/Clients/ObservableTeamsClient.cs
+++ b/Octokit.Reactive/Clients/ObservableTeamsClient.cs
@@ -246,6 +246,25 @@ public IObservable AddRepository(int id, string organization, string repoN
return _client.AddRepository(id, organization, repoName).ToObservable();
}
+ ///
+ /// Adds a to a .
+ ///
+ /// The team identifier.
+ /// Org to associate the repo with.
+ /// Name of the repo.
+ /// The permission to grant the team on this repository.
+ /// Thrown if you attempt to add a repository to a team that is not owned by the organization.
+ ///
+ /// See the API documentation for more information.
+ ///
+ /// if the repository was added to the team; otherwise.
+ public IObservable AddRepository(int id, string organization, string repoName, RepositoryPermissionRequest permission)
+ {
+ Ensure.ArgumentNotNullOrEmptyString(organization, "organization");
+ Ensure.ArgumentNotNullOrEmptyString(repoName, "repoName");
+
+ return _client.AddRepository(id, organization, repoName, permission).ToObservable();
+ }
///
/// Remove a repository from the team
diff --git a/Octokit.Tests.Integration/Clients/Enterprise/EnterpriseLdapClientTests.cs b/Octokit.Tests.Integration/Clients/Enterprise/EnterpriseLdapClientTests.cs
index 5fbac3728e..9548a2b16e 100644
--- a/Octokit.Tests.Integration/Clients/Enterprise/EnterpriseLdapClientTests.cs
+++ b/Octokit.Tests.Integration/Clients/Enterprise/EnterpriseLdapClientTests.cs
@@ -13,7 +13,7 @@ public class EnterpriseLdapClientTests : IDisposable
readonly string _testUser = "test-user";
readonly string _distinguishedNameUser = "uid=test-user,ou=users,dc=company,dc=com";
- readonly EnterpriseTeamContext _context;
+ readonly TeamContext _context;
readonly string _distinguishedNameTeam = "cn=test-team,ou=groups,dc=company,dc=com";
public EnterpriseLdapClientTests()
@@ -21,7 +21,7 @@ public EnterpriseLdapClientTests()
_github = EnterpriseHelper.GetAuthenticatedClient();
NewTeam newTeam = new NewTeam(Helper.MakeNameWithTimestamp("test-team")) { Description = "Test Team" };
- _context = _github.CreateEnterpriseTeamContext(EnterpriseHelper.Organization, newTeam).Result;
+ _context = _github.CreateTeamContext(EnterpriseHelper.Organization, newTeam).Result;
}
[GitHubEnterpriseTest]
diff --git a/Octokit.Tests.Integration/Clients/RepositoriesClientTests.cs b/Octokit.Tests.Integration/Clients/RepositoriesClientTests.cs
index cb715f0bf9..f0bf997226 100644
--- a/Octokit.Tests.Integration/Clients/RepositoriesClientTests.cs
+++ b/Octokit.Tests.Integration/Clients/RepositoriesClientTests.cs
@@ -433,7 +433,7 @@ public async Task UpdatesHasWiki()
public void Dispose()
{
- Helper.DeleteRepo(_repository);
+ Helper.DeleteRepo(Helper.GetAuthenticatedClient().Connection, _repository);
}
}
diff --git a/Octokit.Tests.Integration/Clients/RepositoryForksClientTests.cs b/Octokit.Tests.Integration/Clients/RepositoryForksClientTests.cs
index 3f7c5af777..c1b64c6b88 100644
--- a/Octokit.Tests.Integration/Clients/RepositoryForksClientTests.cs
+++ b/Octokit.Tests.Integration/Clients/RepositoryForksClientTests.cs
@@ -43,7 +43,7 @@ public async Task ForkCreatedForUserLoggedIn()
// The fork is created asynchronously by github and therefore it cannot
// be certain that the repo exists when the test ends. It is therefore deleted
// before the test starts instead of after.
- Helper.DeleteRepo(Helper.Credentials.Login, "octokit.net");
+ Helper.DeleteRepo(Helper.GetAuthenticatedClient().Connection, Helper.Credentials.Login, "octokit.net");
var github = Helper.GetAuthenticatedClient();
@@ -60,7 +60,7 @@ public async Task ForkCreatedForOrganization()
// The fork is created asynchronously by github and therefore it cannot
// be certain that the repo exists when the test ends. It is therefore deleted
// before the test starts.
- Helper.DeleteRepo(Helper.Organization, "octokit.net");
+ Helper.DeleteRepo(Helper.GetAuthenticatedClient().Connection, Helper.Organization, "octokit.net");
var github = Helper.GetAuthenticatedClient();
diff --git a/Octokit.Tests.Integration/Clients/TeamsClientTests.cs b/Octokit.Tests.Integration/Clients/TeamsClientTests.cs
index 1a1609b71f..fecb5c1ded 100644
--- a/Octokit.Tests.Integration/Clients/TeamsClientTests.cs
+++ b/Octokit.Tests.Integration/Clients/TeamsClientTests.cs
@@ -148,4 +148,34 @@ public async Task GetsAllRepositories()
}
}
}
+
+ public class TheAddOrUpdateTeamRepositoryMethod
+ {
+ private readonly IGitHubClient _github;
+
+ public TheAddOrUpdateTeamRepositoryMethod()
+ {
+ _github = Helper.GetAuthenticatedClient();
+ }
+
+ [OrganizationTest]
+ public async Task CanAddRepository()
+ {
+ using (var teamContext = await _github.CreateTeamContext(Helper.Organization, new NewTeam(Helper.MakeNameWithTimestamp("team"))))
+ using (var repoContext = await _github.CreateRepositoryContext(Helper.Organization, new NewRepository(Helper.MakeNameWithTimestamp("team-repository"))))
+ {
+ var team = teamContext.Team;
+ var repo = repoContext.Repository;
+
+ var addRepo = await _github.Organization.Team.AddRepository(team.Id, team.Organization.Login, repo.Name, new RepositoryPermissionRequest(Permission.Admin));
+
+ Assert.True(addRepo);
+
+ var addedRepo = await _github.Organization.Team.GetAllRepositories(team.Id);
+
+ //Check if permission was correctly applied
+ Assert.True(addedRepo.First(x => x.Id == repo.Id).Permissions.Admin == true);
+ }
+ }
+ }
}
diff --git a/Octokit.Tests.Integration/Clients/UserAdministrationClientTests.cs b/Octokit.Tests.Integration/Clients/UserAdministrationClientTests.cs
index 0a68edd27a..08554c5bee 100644
--- a/Octokit.Tests.Integration/Clients/UserAdministrationClientTests.cs
+++ b/Octokit.Tests.Integration/Clients/UserAdministrationClientTests.cs
@@ -79,7 +79,7 @@ public async Task CanRename()
}
// Remove user if it was already renamed
- EnterpriseHelper.DeleteUser(renamedUsername);
+ EnterpriseHelper.DeleteUser(_github.Connection, renamedUsername);
}
[GitHubEnterpriseTest]
diff --git a/Octokit.Tests.Integration/EnterpriseHelper.cs b/Octokit.Tests.Integration/EnterpriseHelper.cs
index baf16c9a33..deae6e0e88 100644
--- a/Octokit.Tests.Integration/EnterpriseHelper.cs
+++ b/Octokit.Tests.Integration/EnterpriseHelper.cs
@@ -108,50 +108,18 @@ public static string ClientSecret
get { return Environment.GetEnvironmentVariable("OCTOKIT_GHE_CLIENTSECRET"); }
}
- public static void DeleteRepo(Repository repository)
- {
- if (repository != null)
- DeleteRepo(repository.Owner.Login, repository.Name);
- }
-
- public static void DeleteRepo(string owner, string name)
- {
- var api = GetAuthenticatedClient();
- try
- {
- api.Repository.Delete(owner, name).Wait(TimeSpan.FromSeconds(15));
- }
- catch { }
- }
-
- public static void DeleteTeam(Team team)
- {
- if (team != null)
- DeleteTeam(team.Id);
- }
-
- public static void DeleteTeam(int teamId)
- {
- var api = GetAuthenticatedClient();
- try
- {
- api.Organization.Team.Delete(teamId).Wait(TimeSpan.FromSeconds(15));
- }
- catch { }
- }
-
- public static void DeleteUser(User user)
+ public static void DeleteUser(IConnection connection, User user)
{
if (user != null)
- DeleteUser(user.Login);
+ DeleteUser(connection, user.Login);
}
- public static void DeleteUser(string username)
+ public static void DeleteUser(IConnection connection, string username)
{
- var api = GetAuthenticatedClient();
try
{
- api.User.Administration.Delete(username).Wait(TimeSpan.FromSeconds(15));
+ var client = new GitHubClient(connection);
+ client.User.Administration.Delete(username).Wait(TimeSpan.FromSeconds(15));
}
catch { }
}
diff --git a/Octokit.Tests.Integration/Helper.cs b/Octokit.Tests.Integration/Helper.cs
index 52eaeb8cb6..f383d37724 100644
--- a/Octokit.Tests.Integration/Helper.cs
+++ b/Octokit.Tests.Integration/Helper.cs
@@ -1,6 +1,7 @@
using System;
using System.Diagnostics;
using System.IO;
+using Octokit.Reactive;
namespace Octokit.Tests.Integration
{
@@ -110,34 +111,50 @@ public static string ClientSecret
get { return Environment.GetEnvironmentVariable("OCTOKIT_CLIENTSECRET"); }
}
- public static void DeleteRepo(Repository repository)
+ public static void DeleteRepo(IConnection connection, Repository repository)
{
if (repository != null)
- DeleteRepo(repository.Owner.Login, repository.Name);
+ DeleteRepo(connection, repository.Owner.Login, repository.Name);
}
- public static void DeleteRepo(string owner, string name)
+ public static void DeleteRepo(IConnection connection, string owner, string name)
{
- var api = GetAuthenticatedClient();
try
{
- api.Repository.Delete(owner, name).Wait(TimeSpan.FromSeconds(15));
+ var client = new GitHubClient(connection);
+ client.Repository.Delete(owner, name).Wait(TimeSpan.FromSeconds(15));
}
catch { }
}
- public static void DeleteKey(PublicKey key)
+ public static void DeleteTeam(IConnection connection, Team team)
+ {
+ if (team != null)
+ DeleteTeam(connection, team.Id);
+ }
+
+ public static void DeleteTeam(IConnection connection, int teamId)
+ {
+ try
+ {
+ var client = new GitHubClient(connection);
+ client.Organization.Team.Delete(teamId).Wait(TimeSpan.FromSeconds(15));
+ }
+ catch { }
+ }
+
+ public static void DeleteKey(IConnection connection, PublicKey key)
{
if (key != null)
- DeleteKey(key.Id);
+ DeleteKey(connection, key.Id);
}
- public static void DeleteKey(int keyId)
+ public static void DeleteKey(IConnection connection, int keyId)
{
- var api = GetAuthenticatedClient();
try
{
- api.User.Keys.Delete(keyId).Wait(TimeSpan.FromSeconds(15));
+ var client = new GitHubClient(connection);
+ client.User.Keys.Delete(keyId).Wait(TimeSpan.FromSeconds(15));
}
catch { }
}
diff --git a/Octokit.Tests.Integration/Helpers/EnterpriseUserContext.cs b/Octokit.Tests.Integration/Helpers/EnterpriseUserContext.cs
index 496fb52d3c..177a8c6902 100644
--- a/Octokit.Tests.Integration/Helpers/EnterpriseUserContext.cs
+++ b/Octokit.Tests.Integration/Helpers/EnterpriseUserContext.cs
@@ -8,14 +8,16 @@ namespace Octokit.Tests.Integration.Helpers
{
internal sealed class EnterpriseUserContext : IDisposable
{
- internal EnterpriseUserContext(User user)
+ internal EnterpriseUserContext(IConnection connection, User user)
{
+ _connection = connection;
User = user;
UserId = user.Id;
UserLogin = user.Login;
UserEmail = user.Email;
}
+ private IConnection _connection;
internal int UserId { get; private set; }
internal string UserLogin { get; private set; }
internal string UserEmail { get; private set; }
@@ -24,7 +26,7 @@ internal EnterpriseUserContext(User user)
public void Dispose()
{
- EnterpriseHelper.DeleteUser(User);
+ EnterpriseHelper.DeleteUser(_connection, User.Login);
}
}
}
diff --git a/Octokit.Tests.Integration/Helpers/GithubClientExtensions.cs b/Octokit.Tests.Integration/Helpers/GithubClientExtensions.cs
index 8f982e43c4..18604004ee 100644
--- a/Octokit.Tests.Integration/Helpers/GithubClientExtensions.cs
+++ b/Octokit.Tests.Integration/Helpers/GithubClientExtensions.cs
@@ -9,35 +9,35 @@ internal static async Task CreateRepositoryContext(this IGitH
var repoName = Helper.MakeNameWithTimestamp(repositoryName);
var repo = await client.Repository.Create(new NewRepository(repoName) { AutoInit = true });
- return new RepositoryContext(repo);
+ return new RepositoryContext(client.Connection, repo);
}
internal static async Task CreateRepositoryContext(this IGitHubClient client, string organizationLogin, NewRepository newRepository)
{
var repo = await client.Repository.Create(organizationLogin, newRepository);
- return new RepositoryContext(repo);
+ return new RepositoryContext(client.Connection, repo);
}
internal static async Task CreateRepositoryContext(this IGitHubClient client, NewRepository newRepository)
{
var repo = await client.Repository.Create(newRepository);
- return new RepositoryContext(repo);
+ return new RepositoryContext(client.Connection, repo);
}
- internal static async Task CreateEnterpriseTeamContext(this IGitHubClient client, string organization, NewTeam newTeam)
+ internal static async Task CreateTeamContext(this IGitHubClient client, string organization, NewTeam newTeam)
{
var team = await client.Organization.Team.Create(organization, newTeam);
- return new EnterpriseTeamContext(team);
+ return new TeamContext(client.Connection, team);
}
internal static async Task CreateEnterpriseUserContext(this IGitHubClient client, NewUser newUser)
{
var user = await client.User.Administration.Create(newUser);
- return new EnterpriseUserContext(user);
+ return new EnterpriseUserContext(client.Connection, user);
}
internal static async Task CreatePublicKeyContext(this IGitHubClient client)
@@ -48,7 +48,7 @@ internal static async Task CreatePublicKeyContext(this IGitHub
var key = await client.User.Keys.Create(new NewPublicKey(keyTitle, keyData));
- return new PublicKeyContext(key);
+ return new PublicKeyContext(client.Connection, key);
}
}
}
\ No newline at end of file
diff --git a/Octokit.Tests.Integration/Helpers/ObservableGithubClientExtensions.cs b/Octokit.Tests.Integration/Helpers/ObservableGithubClientExtensions.cs
index f455608a95..12ab85f23b 100644
--- a/Octokit.Tests.Integration/Helpers/ObservableGithubClientExtensions.cs
+++ b/Octokit.Tests.Integration/Helpers/ObservableGithubClientExtensions.cs
@@ -11,35 +11,35 @@ internal static async Task CreateRepositoryContext(this IObse
var repoName = Helper.MakeNameWithTimestamp(repositoryName);
var repo = await client.Repository.Create(new NewRepository(repoName) { AutoInit = true });
- return new RepositoryContext(repo);
+ return new RepositoryContext(client.Connection, repo);
}
internal static async Task CreateRepositoryContext(this IObservableGitHubClient client, string organizationLogin, NewRepository newRepository)
{
var repo = await client.Repository.Create(organizationLogin, newRepository);
- return new RepositoryContext(repo);
+ return new RepositoryContext(client.Connection, repo);
}
internal static async Task CreateRepositoryContext(this IObservableGitHubClient client, NewRepository newRepository)
{
var repo = await client.Repository.Create(newRepository);
- return new RepositoryContext(repo);
+ return new RepositoryContext(client.Connection, repo);
}
- internal static async Task CreateEnterpriseTeamContext(this IObservableGitHubClient client, string organization, NewTeam newTeam)
+ internal static async Task CreateEnterpriseTeamContext(this IObservableGitHubClient client, string organization, NewTeam newTeam)
{
var team = await client.Organization.Team.Create(organization, newTeam);
- return new EnterpriseTeamContext(team);
+ return new TeamContext(client.Connection, team);
}
internal static async Task CreateEnterpriseUserContext(this IObservableGitHubClient client, NewUser newUser)
{
var user = await client.User.Administration.Create(newUser);
- return new EnterpriseUserContext(user);
+ return new EnterpriseUserContext(client.Connection, user);
}
internal static async Task CreatePublicKeyContext(this IObservableGitHubClient client)
@@ -50,7 +50,7 @@ internal static async Task CreatePublicKeyContext(this IObserv
var key = await client.User.Keys.Create(new NewPublicKey(keyTitle, keyData));
- return new PublicKeyContext(key);
+ return new PublicKeyContext(client.Connection, key);
}
}
}
\ No newline at end of file
diff --git a/Octokit.Tests.Integration/Helpers/PublicKeyContext.cs b/Octokit.Tests.Integration/Helpers/PublicKeyContext.cs
index 30fbaac79c..bf4b2d3292 100644
--- a/Octokit.Tests.Integration/Helpers/PublicKeyContext.cs
+++ b/Octokit.Tests.Integration/Helpers/PublicKeyContext.cs
@@ -8,14 +8,16 @@ namespace Octokit.Tests.Integration.Helpers
{
internal sealed class PublicKeyContext : IDisposable
{
- internal PublicKeyContext(PublicKey key)
+ internal PublicKeyContext(IConnection connection, PublicKey key)
{
+ _connection = connection;
Key = key;
KeyId = key.Id;
KeyTitle = key.Title;
KeyData = key.Key;
}
+ private IConnection _connection;
internal int KeyId { get; private set; }
internal string KeyTitle { get; private set; }
internal string KeyData { get; private set; }
@@ -24,7 +26,7 @@ internal PublicKeyContext(PublicKey key)
public void Dispose()
{
- Helper.DeleteKey(Key);
+ Helper.DeleteKey(_connection, Key);
}
}
}
diff --git a/Octokit.Tests.Integration/Helpers/RepositoryContext.cs b/Octokit.Tests.Integration/Helpers/RepositoryContext.cs
index d16afd36de..509cba7a3a 100644
--- a/Octokit.Tests.Integration/Helpers/RepositoryContext.cs
+++ b/Octokit.Tests.Integration/Helpers/RepositoryContext.cs
@@ -3,18 +3,21 @@
using System.Linq;
using System.Text;
using System.Threading.Tasks;
+using Octokit.Reactive;
namespace Octokit.Tests.Integration.Helpers
{
internal sealed class RepositoryContext : IDisposable
{
- internal RepositoryContext(Repository repo)
+ internal RepositoryContext(IConnection connection, Repository repo)
{
+ _connection = connection;
Repository = repo;
RepositoryOwner = repo.Owner.Login;
RepositoryName = repo.Name;
}
+ private IConnection _connection;
internal string RepositoryOwner { get; private set; }
internal string RepositoryName { get; private set; }
@@ -22,7 +25,7 @@ internal RepositoryContext(Repository repo)
public void Dispose()
{
- Helper.DeleteRepo(Repository);
+ Helper.DeleteRepo(_connection, Repository);
}
}
}
diff --git a/Octokit.Tests.Integration/Helpers/EnterpriseTeamContext.cs b/Octokit.Tests.Integration/Helpers/TeamContext.cs
similarity index 66%
rename from Octokit.Tests.Integration/Helpers/EnterpriseTeamContext.cs
rename to Octokit.Tests.Integration/Helpers/TeamContext.cs
index 3b910a2af3..c1479c4c4d 100644
--- a/Octokit.Tests.Integration/Helpers/EnterpriseTeamContext.cs
+++ b/Octokit.Tests.Integration/Helpers/TeamContext.cs
@@ -6,15 +6,17 @@
namespace Octokit.Tests.Integration.Helpers
{
- internal sealed class EnterpriseTeamContext : IDisposable
+ internal sealed class TeamContext : IDisposable
{
- internal EnterpriseTeamContext(Team team)
+ internal TeamContext(IConnection connection, Team team)
{
+ _connection = connection;
Team = team;
TeamId = team.Id;
TeamName = team.Name;
}
+ private IConnection _connection;
internal int TeamId { get; private set; }
internal string TeamName { get; private set; }
@@ -22,7 +24,7 @@ internal EnterpriseTeamContext(Team team)
public void Dispose()
{
- EnterpriseHelper.DeleteTeam(Team);
+ Helper.DeleteTeam(_connection, Team);
}
}
}
diff --git a/Octokit.Tests.Integration/Octokit.Tests.Integration.csproj b/Octokit.Tests.Integration/Octokit.Tests.Integration.csproj
index be61279eb1..afe0511eb7 100644
--- a/Octokit.Tests.Integration/Octokit.Tests.Integration.csproj
+++ b/Octokit.Tests.Integration/Octokit.Tests.Integration.csproj
@@ -127,7 +127,7 @@
-
+
diff --git a/Octokit.Tests.Integration/Reactive/Enterprise/ObservableEnterpriseLdapClientTests.cs b/Octokit.Tests.Integration/Reactive/Enterprise/ObservableEnterpriseLdapClientTests.cs
index 948a52a65a..01441e963b 100644
--- a/Octokit.Tests.Integration/Reactive/Enterprise/ObservableEnterpriseLdapClientTests.cs
+++ b/Octokit.Tests.Integration/Reactive/Enterprise/ObservableEnterpriseLdapClientTests.cs
@@ -15,7 +15,7 @@ public class ObservableEnterpriseLdapClientTests : IDisposable
readonly string _testUser = "test-user";
readonly string _distinguishedNameUser = "uid=test-user,ou=users,dc=company,dc=com";
- readonly EnterpriseTeamContext _context;
+ readonly TeamContext _context;
readonly string _distinguishedNameTeam = "cn=test-team,ou=groups,dc=company,dc=com";
public ObservableEnterpriseLdapClientTests()
diff --git a/Octokit.Tests.Integration/Reactive/ObservableRepositoryDeployKeysClientTests.cs b/Octokit.Tests.Integration/Reactive/ObservableRepositoryDeployKeysClientTests.cs
index 1cf8b6067e..5a6ba833c6 100644
--- a/Octokit.Tests.Integration/Reactive/ObservableRepositoryDeployKeysClientTests.cs
+++ b/Octokit.Tests.Integration/Reactive/ObservableRepositoryDeployKeysClientTests.cs
@@ -101,6 +101,6 @@ public async Task CanRemoveADeployKey()
public void Dispose()
{
- Helper.DeleteRepo(_repository);
+ Helper.DeleteRepo(Helper.GetAuthenticatedClient().Connection, _repository);
}
}
\ No newline at end of file
diff --git a/Octokit.Tests.Integration/Reactive/ObservableUserAdministrationClientTests.cs b/Octokit.Tests.Integration/Reactive/ObservableUserAdministrationClientTests.cs
index ad15c40233..eb2f8a9a4e 100644
--- a/Octokit.Tests.Integration/Reactive/ObservableUserAdministrationClientTests.cs
+++ b/Octokit.Tests.Integration/Reactive/ObservableUserAdministrationClientTests.cs
@@ -82,7 +82,7 @@ public async Task CanRename()
}
// Remove user if it was already renamed
- EnterpriseHelper.DeleteUser(renamedUsername);
+ EnterpriseHelper.DeleteUser(_github.Connection, renamedUsername);
}
[GitHubEnterpriseTest]
diff --git a/Octokit.Tests/Clients/TeamsClientTests.cs b/Octokit.Tests/Clients/TeamsClientTests.cs
index 7793074405..1d06195a55 100644
--- a/Octokit.Tests/Clients/TeamsClientTests.cs
+++ b/Octokit.Tests/Clients/TeamsClientTests.cs
@@ -3,6 +3,7 @@
using System.Threading.Tasks;
using NSubstitute;
using Xunit;
+using System.Net;
namespace Octokit.Tests.Clients
{
@@ -302,6 +303,18 @@ public void RequestsTheCorrectUrl()
connection.Connection.Received().Put(Arg.Is(u => u.ToString() == "teams/1/repos/org/repo"));
}
+ [Fact]
+ public void AddOrUpdatePermission()
+ {
+ var connection = Substitute.For();
+ var client = new TeamsClient(connection);
+ var newPermission = new RepositoryPermissionRequest(Permission.Admin);
+
+ client.AddRepository(1, "org", "repo", newPermission);
+
+ connection.Connection.Received().Put(Arg.Is(u => u.ToString() == "teams/1/repos/org/repo"), Arg.Any