mirror of
https://github.com/zoriya/octokit.net.git
synced 2026-06-07 20:30:41 +00:00
Surface exceptions in RepoCollaboratorsClient.Add method (#1576)
* Surface exceptions in RepoCollaboratorsClient.Add method * Reintroducing try...catch but for NotFoundException * Remove old/test dotnet core builds from appveyor
This commit is contained in:
committed by
Ryan Gribble
parent
dba2b7bdc2
commit
596e51d5b3
@@ -227,6 +227,30 @@ namespace Octokit.Tests.Clients
|
||||
await Assert.ThrowsAsync<ArgumentException>(() => client.Add("owner", "test", ""));
|
||||
await Assert.ThrowsAsync<ArgumentException>(() => client.Add(1, ""));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task SurfacesAuthorizationException()
|
||||
{
|
||||
var connection = Substitute.For<IApiConnection>();
|
||||
var client = new RepoCollaboratorsClient(connection);
|
||||
|
||||
connection.Put(Arg.Any<Uri>()).Returns(x => { throw new AuthorizationException(); });
|
||||
|
||||
await Assert.ThrowsAsync<AuthorizationException>(() => client.Add("owner", "test", "user1"));
|
||||
await Assert.ThrowsAsync<AuthorizationException>(() => client.Add(1, "user1"));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task SurfacesAuthorizationExceptionWhenSpecifyingCollaboratorRequest()
|
||||
{
|
||||
var connection = Substitute.For<IApiConnection>();
|
||||
var client = new RepoCollaboratorsClient(connection);
|
||||
|
||||
connection.Connection.Put<object>(Arg.Any<Uri>(), Arg.Any<object>()).ThrowsAsync(new AuthorizationException());
|
||||
|
||||
await Assert.ThrowsAsync<AuthorizationException>(() => client.Add("owner", "test", "user1", new CollaboratorRequest(Permission.Pull)));
|
||||
await Assert.ThrowsAsync<AuthorizationException>(() => client.Add(1, "user1", new CollaboratorRequest(Permission.Pull)));
|
||||
}
|
||||
}
|
||||
|
||||
public class TheInviteMethod
|
||||
|
||||
@@ -175,11 +175,11 @@ namespace Octokit
|
||||
Ensure.ArgumentNotNullOrEmptyString(user, "user");
|
||||
|
||||
try
|
||||
{
|
||||
{
|
||||
var response = await Connection.Put<object>(ApiUrls.RepoCollaborator(owner, name, user), permission).ConfigureAwait(false);
|
||||
return response.HttpResponse.IsTrue();
|
||||
}
|
||||
catch
|
||||
catch (NotFoundException)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@@ -220,7 +220,7 @@ namespace Octokit
|
||||
var response = await Connection.Put<object>(ApiUrls.RepoCollaborator(repositoryId, user), permission).ConfigureAwait(false);
|
||||
return response.HttpResponse.IsTrue();
|
||||
}
|
||||
catch
|
||||
catch (NotFoundException)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
+1
-2
@@ -5,8 +5,7 @@ build_script:
|
||||
- cmd: build.cmd UnitTests
|
||||
- cmd: build.cmd ConventionTests
|
||||
- cmd: build.cmd CreatePackages
|
||||
- cmd: build.cmd UnitTestsDotNetCore
|
||||
test: off
|
||||
artifacts:
|
||||
- path: 'packaging\octokit*.nupkg'
|
||||
name: OctokitPackages
|
||||
name: OctokitPackages
|
||||
|
||||
Reference in New Issue
Block a user