Fix async tests (#1631)

* Fix up Assert.ThrowsAsync tests to actually await the call

* ... and it even picked up a missing null check... pay day!
This commit is contained in:
Ryan Gribble
2017-07-23 09:03:10 +10:00
committed by GitHub
parent 329ef960ed
commit db74c3b4ad
12 changed files with 80 additions and 73 deletions
@@ -184,7 +184,7 @@ namespace Octokit.Tests.Integration.Clients
Assert.Equal(created.Token, applicationAuthorization.Token);
await github.Authorization.Delete(created.Id);
Assert.ThrowsAsync<NotFoundException>(() => github.Authorization.Get(created.Id));
await Assert.ThrowsAsync<NotFoundException>(() => github.Authorization.Get(created.Id));
}
[BasicAuthenticationTest]
@@ -210,7 +210,7 @@ namespace Octokit.Tests.Integration.Clients
Assert.NotEqual(created.Token, applicationAuthorization.Token);
await github.Authorization.Delete(created.Id);
Assert.ThrowsAsync<NotFoundException>(() => github.Authorization.Get(created.Id));
await Assert.ThrowsAsync<NotFoundException>(() => github.Authorization.Get(created.Id));
}
[BasicAuthenticationTest]
@@ -232,8 +232,8 @@ namespace Octokit.Tests.Integration.Clients
var applicationClient = Helper.GetAuthenticatedApplicationClient();
await applicationClient.Authorization.RevokeApplicationAuthentication(Helper.ClientId, created.Token);
Assert.ThrowsAsync<NotFoundException>(() => applicationClient.Authorization.CheckApplicationAuthentication(Helper.ClientId, created.Token));
Assert.ThrowsAsync<NotFoundException>(() => github.Authorization.Get(created.Id));
await Assert.ThrowsAsync<NotFoundException>(() => applicationClient.Authorization.CheckApplicationAuthentication(Helper.ClientId, created.Token));
await Assert.ThrowsAsync<NotFoundException>(() => github.Authorization.Get(created.Id));
}
}
}
@@ -148,7 +148,7 @@ public class PullRequestReviewCommentsClientTests : IDisposable
await _client.Delete(Helper.UserName, _context.RepositoryName, createdComment.Id);
Assert.ThrowsAsync<NotFoundException>(() => _client.GetComment(Helper.UserName, _context.RepositoryName, createdComment.Id));
await Assert.ThrowsAsync<NotFoundException>(() => _client.GetComment(Helper.UserName, _context.RepositoryName, createdComment.Id));
}
[IntegrationTest]
@@ -163,7 +163,7 @@ public class PullRequestReviewCommentsClientTests : IDisposable
await _client.Delete(_context.Repository.Id, createdComment.Id);
Assert.ThrowsAsync<NotFoundException>(() => _client.GetComment(_context.Repository.Id, createdComment.Id));
await Assert.ThrowsAsync<NotFoundException>(() => _client.GetComment(_context.Repository.Id, createdComment.Id));
}
[IntegrationTest]
@@ -788,7 +788,7 @@ public class ReleasesClientTests
await _releaseClient.DeleteAsset(_context.RepositoryOwner, _context.RepositoryName, result.Id);
Assert.ThrowsAsync<NotFoundException>(async () => await _releaseClient.DeleteAsset(_context.RepositoryOwner, _context.RepositoryName, result.Id));
await Assert.ThrowsAsync<NotFoundException>(async () => await _releaseClient.DeleteAsset(_context.RepositoryOwner, _context.RepositoryName, result.Id));
}
[IntegrationTest]
@@ -806,7 +806,7 @@ public class ReleasesClientTests
Assert.NotNull(asset);
Assert.ThrowsAsync<NotFoundException>(async () => await _releaseClient.DeleteAsset(_context.Repository.Id, result.Id));
await Assert.ThrowsAsync<NotFoundException>(async () => await _releaseClient.DeleteAsset(_context.Repository.Id, result.Id));
}
}
@@ -836,7 +836,7 @@ public class ReleasesClientTests
await _releaseClient.Delete(_context.RepositoryOwner, _context.RepositoryName, createdRelease.Id);
Assert.ThrowsAsync<NotFoundException>(async () => await _releaseClient.Get(_context.RepositoryOwner, _context.RepositoryName, createdRelease.Id));
await Assert.ThrowsAsync<NotFoundException>(async () => await _releaseClient.Get(_context.RepositoryOwner, _context.RepositoryName, createdRelease.Id));
}
[IntegrationTest]
@@ -851,7 +851,7 @@ public class ReleasesClientTests
await _releaseClient.Delete(_context.Repository.Id, createdRelease.Id);
Assert.ThrowsAsync<NotFoundException>(async () => await _releaseClient.Get(_context.Repository.Id, createdRelease.Id));
await Assert.ThrowsAsync<NotFoundException>(async () => await _releaseClient.Get(_context.Repository.Id, createdRelease.Id));
}
}
}
@@ -92,7 +92,7 @@ VO/+BCBsaoT4g1FFOmJhbBAD3G72yslBnUJmqKP/39pi
var key = await github.User.GpgKey.Create(new NewGpgKey(publicKey));
Assert.NotNull(key);
Assert.ThrowsAsync<ApiValidationException>(async () => await github.User.GpgKey.Create(new NewGpgKey(publicKey)));
await Assert.ThrowsAsync<ApiValidationException>(async () => await github.User.GpgKey.Create(new NewGpgKey(publicKey)));
await github.User.GpgKey.Delete(key.Id);
var keys = await github.User.GpgKey.GetAllForCurrent();