mirror of
https://github.com/zoriya/octokit.net.git
synced 2026-06-03 03:01:31 +00:00
RepositoryExistsException has now two constructors (one for account and one for organization)
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Octokit;
|
||||
@@ -253,7 +254,7 @@ public class RepositoriesClientTests
|
||||
}
|
||||
}
|
||||
|
||||
[IntegrationTest(Skip="this test is bollocks")]
|
||||
[IntegrationTest]
|
||||
public async Task ThrowsRepositoryExistsExceptionForExistingRepository()
|
||||
{
|
||||
var github = Helper.GetAuthenticatedClient();
|
||||
@@ -263,11 +264,14 @@ public class RepositoriesClientTests
|
||||
|
||||
try
|
||||
{
|
||||
var message = string.Format(CultureInfo.InvariantCulture, "There is already a repository named '{0}' for the current account.", repoName);
|
||||
|
||||
var thrown = await AssertEx.Throws<RepositoryExistsException>(
|
||||
async () => await github.Repository.Create(repository));
|
||||
|
||||
Assert.NotNull(thrown);
|
||||
Assert.Equal(repoName, thrown.RepositoryName);
|
||||
Assert.Equal(Helper.Credentials.Login, thrown.Owner);
|
||||
Assert.Equal(message, thrown.Message);
|
||||
Assert.False(thrown.OwnerIsOrganization);
|
||||
}
|
||||
finally
|
||||
@@ -347,6 +351,37 @@ public class RepositoriesClientTests
|
||||
}
|
||||
}
|
||||
|
||||
[IntegrationTest]
|
||||
public async Task ThrowsRepositoryExistsExceptionForExistingRepository()
|
||||
{
|
||||
var github = Helper.GetAuthenticatedClient();
|
||||
|
||||
var repoName = Helper.MakeNameWithTimestamp("existing-org-repo");
|
||||
|
||||
var repository = new NewRepository { Name = repoName };
|
||||
var createdRepository = await github.Repository.Create(Helper.Organization, repository);
|
||||
|
||||
try
|
||||
{
|
||||
var repositoryUrl = string.Format(CultureInfo.InvariantCulture, "https://github.com/{0}/{1}", Helper.Organization, repository.Name);
|
||||
var message = string.Format(CultureInfo.InvariantCulture, "There is already a repository named '{0}' in the organization '{1}'.", repository.Name, Helper.Organization);
|
||||
|
||||
var thrown = await AssertEx.Throws<RepositoryExistsException>(
|
||||
async () => await github.Repository.Create(Helper.Organization, repository));
|
||||
|
||||
Assert.NotNull(thrown);
|
||||
Assert.Equal(repoName, thrown.RepositoryName);
|
||||
Assert.Equal(message, thrown.Message);
|
||||
Assert.True(thrown.OwnerIsOrganization);
|
||||
Assert.Equal(Helper.Organization, thrown.Organization);
|
||||
Assert.Equal(repositoryUrl, thrown.ExistingRepositoryWebUrl.ToString());
|
||||
}
|
||||
finally
|
||||
{
|
||||
Helper.DeleteRepo(createdRepository);
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: Add a test for the team_id param once an overload that takes an oranization is added
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user