Add exception for exceeding the private quota

This commit is contained in:
Haacked
2014-02-18 22:41:19 -08:00
parent 8fa98fa99a
commit 34ac57ccab
9 changed files with 133 additions and 3 deletions
@@ -9,7 +9,7 @@ using Octokit.Tests.Helpers;
public class RepositoriesClientTests
{
public class TheCreateMethodForUser
public class TheCreateMethodForUser : IDisposable
{
[IntegrationTest]
public async Task CreatesANewPublicRepository()
@@ -287,6 +287,45 @@ public class RepositoriesClientTests
Helper.DeleteRepo(createdRepository);
}
}
[IntegrationTest]
public async Task ThrowsPrivateRepositoryQuotaExceededExceptionWhenOverQuota()
{
var github = new GitHubClient(new ProductHeaderValue("OctokitTests"))
{
Credentials = Helper.Credentials
};
for (int i = 0; i < 5; i++)
{
var repoName = Helper.MakeNameWithTimestamp("private-repo" + i);
var repository = new NewRepository { Name = repoName, Private = true };
await github.Repository.Create(repository);
}
var thrown = await AssertEx.Throws<PrivateRepositoryQuotaExceededException>(
async () => await github.Repository.Create(new NewRepository { Name = "x-private", Private = true }));
Assert.NotNull(thrown);
}
// Clean up the repos.
public void Dispose()
{
var github = new GitHubClient(new ProductHeaderValue("OctokitTests"))
{
Credentials = Helper.Credentials
};
var repositories = github.Repository.GetAllForCurrent().Result;
foreach (var repository in repositories)
{
try
{
github.Repository.Delete(repository.Owner.Login, repository.Name).Wait();
}
catch (Exception) { }
}
}
}
public class TheCreateMethodForOrganization