diff --git a/Octokit.Tests.Integration/Clients/RepositoriesClientTests.cs b/Octokit.Tests.Integration/Clients/RepositoriesClientTests.cs index 6aeb8fc2..c3fba05f 100644 --- a/Octokit.Tests.Integration/Clients/RepositoriesClientTests.cs +++ b/Octokit.Tests.Integration/Clients/RepositoriesClientTests.cs @@ -408,44 +408,6 @@ public class RepositoriesClientTests Assert.False(thrown.OwnerIsOrganization); } } - - [PaidAccountTest(Skip = "Paid plans now have unlimited repositories. We shouldn't test this now.")] - public async Task ThrowsPrivateRepositoryQuotaExceededExceptionWhenOverQuota() - { - var github = Helper.GetAuthenticatedClient(); - - var userDetails = await github.User.Current(); - var freePrivateSlots = userDetails.Plan.PrivateRepos - userDetails.OwnedPrivateRepos; - - if (userDetails.Plan.PrivateRepos == 0) - { - throw new Exception("Test cannot complete, account is on free plan"); - } - - var createRepoTasks = - Enumerable.Range(0, (int)freePrivateSlots) - .Select(x => - { - var repoName = Helper.MakeNameWithTimestamp("private-repo-" + x); - var repository = new NewRepository(repoName) { Private = true }; - return github.Repository.Create(repository); - }); - - var createdRepositories = await Task.WhenAll(createRepoTasks); - - try - { - await Assert.ThrowsAsync( - () => github.Repository.Create(new NewRepository("x-private") { Private = true })); - } - finally - { - var deleteRepos = createdRepositories - .Select(repo => github.Repository.Delete(repo.Owner.Login, repo.Name)); - - Task.WhenAll(deleteRepos).Wait(); - } - } } public class TheCreateMethodForOrganization diff --git a/Octokit.Tests/Clients/RepositoriesClientTests.cs b/Octokit.Tests/Clients/RepositoriesClientTests.cs index 7a7a8887..c2a77a05 100644 --- a/Octokit.Tests/Clients/RepositoriesClientTests.cs +++ b/Octokit.Tests/Clients/RepositoriesClientTests.cs @@ -85,30 +85,6 @@ namespace Octokit.Tests.Clients Assert.Equal("aName", exception.RepositoryName); Assert.Null(exception.ExistingRepositoryWebUrl); } - - [Fact] - public async Task ThrowsExceptionWhenPrivateRepositoryQuotaExceeded() - { - var newRepository = new NewRepository("aName") { Private = true }; - var response = Substitute.For(); - response.StatusCode.Returns((HttpStatusCode)422); - response.Body.Returns(@"{""message"":""Validation Failed"",""documentation_url"":" - + @"""http://developer.github.com/v3/repos/#create"",""errors"":[{""resource"":""Repository""," - + @"""code"":""custom"",""field"":""name"",""message"":" - + @"""name can't be private. You are over your quota.""}]}"); - var credentials = new Credentials("haacked", "pwd"); - var connection = Substitute.For(); - connection.Connection.BaseAddress.Returns(GitHubClient.GitHubApiUrl); - connection.Connection.Credentials.Returns(credentials); - connection.Post(Args.Uri, newRepository, "application/vnd.github.nebula-preview+json,application/vnd.github.baptiste-preview+json") - .Returns>(_ => { throw new ApiValidationException(response); }); - var client = new RepositoriesClient(connection); - - var exception = await Assert.ThrowsAsync( - () => client.Create(newRepository)); - - Assert.NotNull(exception); - } } public class TheCreateMethodForOrganization diff --git a/Octokit/Clients/RepositoriesClient.cs b/Octokit/Clients/RepositoriesClient.cs index df7d3f4f..46b10519 100644 --- a/Octokit/Clients/RepositoriesClient.cs +++ b/Octokit/Clients/RepositoriesClient.cs @@ -131,22 +131,6 @@ namespace Octokit baseAddress, e); } - if (string.Equals( - "please upgrade your plan to create a new private repository.", - errorMessage, - StringComparison.OrdinalIgnoreCase)) - { - throw new PrivateRepositoryQuotaExceededException(e); - } - - if (string.Equals( - "name can't be private. You are over your quota.", - errorMessage, - StringComparison.OrdinalIgnoreCase)) - { - throw new PrivateRepositoryQuotaExceededException(e); - } - if (errorMessage != null && errorMessage.EndsWith("is an unknown gitignore template.", StringComparison.OrdinalIgnoreCase)) { throw new InvalidGitIgnoreTemplateException(e); diff --git a/Octokit/Exceptions/PrivateRepositoryQuotaExceededException.cs b/Octokit/Exceptions/PrivateRepositoryQuotaExceededException.cs deleted file mode 100644 index c811b1ff..00000000 --- a/Octokit/Exceptions/PrivateRepositoryQuotaExceededException.cs +++ /dev/null @@ -1,58 +0,0 @@ -using System; -using System.Diagnostics.CodeAnalysis; -#if !NO_SERIALIZABLE -using System.Runtime.Serialization; -#endif - -namespace Octokit -{ - /// - /// Exception thrown when creating a private repository, but the user's private quota is or would be exceeded - /// by creating it. - /// -#if !NO_SERIALIZABLE - [Serializable] -#endif - [SuppressMessage("Microsoft.Design", "CA1032:ImplementStandardExceptionConstructors", - Justification = "These exceptions are specific to the GitHub API and not general purpose exceptions")] - public class PrivateRepositoryQuotaExceededException : ApiValidationException - { - /// - /// Constructs an instance of PrivateRepositoryQuotaExceededException. - /// - /// The inner validation exception. - public PrivateRepositoryQuotaExceededException(ApiValidationException innerException) - : base(innerException) - { - } - - public override string Message - { - get - { - // TODO: Would be nice to show the actual numbers, but that requires another request. - return "You are currently at your limit of private repositories. Either delete a private repository you no " - + "longer use (https://help.github.com/articles/deleting-a-repository/) or upgrade your account to a plan " - + "that allows for more private repositories (https://help.github.com/articles/what-plan-should-i-choose/)."; - } - } - -#if !NO_SERIALIZABLE - /// - /// Constructs an instance of PrivateRepositoryQuotaExceededException - /// - /// - /// The that holds the - /// serialized object data about the exception being thrown. - /// - /// - /// The that contains - /// contextual information about the source or destination. - /// - protected PrivateRepositoryQuotaExceededException(SerializationInfo info, StreamingContext context) - : base(info, context) - { - } -#endif - } -}