diff --git a/Octokit.Tests.Integration/Clients/DeploymentStatusClientTests.cs b/Octokit.Tests.Integration/Clients/DeploymentStatusClientTests.cs index 49ee43ef..4c6ae338 100644 --- a/Octokit.Tests.Integration/Clients/DeploymentStatusClientTests.cs +++ b/Octokit.Tests.Integration/Clients/DeploymentStatusClientTests.cs @@ -55,6 +55,17 @@ public class DeploymentStatusClientTests : IDisposable Assert.Equal(DeploymentState.Success, status.State); } + [IntegrationTest] + public async Task CanCreateDeploymentStatusWithRepositoryId() + { + var newStatus = new NewDeploymentStatus(DeploymentState.Success); + + var status = await _deploymentsClient.Status.Create(_context.Repository.Id, _deployment.Id, newStatus); + + Assert.NotNull(status); + Assert.Equal(DeploymentState.Success, status.State); + } + [IntegrationTest] public async Task CanReadDeploymentStatuses() { @@ -69,6 +80,18 @@ public class DeploymentStatusClientTests : IDisposable Assert.Equal(newStatus.EnvironmentUrl, statuses[0].EnvironmentUrl); } + [IntegrationTest] + public async Task CanReadDeploymentStatusesWithRepositoryId() + { + var newStatus = new NewDeploymentStatus(DeploymentState.Success); + await _deploymentsClient.Status.Create(_context.Repository.Id, _deployment.Id, newStatus); + + var statuses = await _deploymentsClient.Status.GetAll(_context.Repository.Id, _deployment.Id); + + Assert.NotEmpty(statuses); + Assert.Equal(DeploymentState.Success, statuses[0].State); + } + [IntegrationTest] public async Task ReturnsCorrectCountOfDeploymentStatusesWithoutStart() { @@ -90,6 +113,27 @@ public class DeploymentStatusClientTests : IDisposable Assert.Equal(3, deploymentStatuses.Count); } + [IntegrationTest] + public async Task ReturnsCorrectCountOfDeploymentStatusesWithoutStartWithRepositoryId() + { + var newStatus1 = new NewDeploymentStatus(DeploymentState.Success); + var newStatus2 = new NewDeploymentStatus(DeploymentState.Success); + var newStatus3 = new NewDeploymentStatus(DeploymentState.Success); + await _deploymentsClient.Status.Create(_context.Repository.Id, _deployment.Id, newStatus1); + await _deploymentsClient.Status.Create(_context.Repository.Id, _deployment.Id, newStatus2); + await _deploymentsClient.Status.Create(_context.Repository.Id, _deployment.Id, newStatus3); + + var options = new ApiOptions + { + PageSize = 3, + PageCount = 1 + }; + + var deploymentStatuses = await _deploymentsClient.Status.GetAll(_context.Repository.Id, _deployment.Id, options); + + Assert.Equal(3, deploymentStatuses.Count); + } + [IntegrationTest] public async Task ReturnsCorrectCountOfDeploymentStatusesWithStart() { @@ -112,6 +156,28 @@ public class DeploymentStatusClientTests : IDisposable Assert.Equal(1, deploymentStatuses.Count); } + [IntegrationTest] + public async Task ReturnsCorrectCountOfDeploymentStatusesWithStartWithRepositoryId() + { + var newStatus1 = new NewDeploymentStatus(DeploymentState.Success); + var newStatus2 = new NewDeploymentStatus(DeploymentState.Success); + var newStatus3 = new NewDeploymentStatus(DeploymentState.Success); + await _deploymentsClient.Status.Create(_context.Repository.Id,_deployment.Id, newStatus1); + await _deploymentsClient.Status.Create(_context.Repository.Id, _deployment.Id, newStatus2); + await _deploymentsClient.Status.Create(_context.Repository.Id, _deployment.Id, newStatus3); + + var options = new ApiOptions + { + PageSize = 2, + PageCount = 1, + StartPage = 2 + }; + + var deploymentStatuses = await _deploymentsClient.Status.GetAll(_context.Repository.Id, _deployment.Id, options); + + Assert.Equal(1, deploymentStatuses.Count); + } + [IntegrationTest] public async Task ReturnsDistinctDeploymentStatusesBasedOnStartPage() { @@ -142,6 +208,36 @@ public class DeploymentStatusClientTests : IDisposable Assert.NotEqual(firstPage[0].Id, secondPage[0].Id); } + [IntegrationTest] + public async Task ReturnsDistinctDeploymentStatusesBasedOnStartPageWithRepositoryId() + { + var newStatus1 = new NewDeploymentStatus(DeploymentState.Success); + var newStatus2 = new NewDeploymentStatus(DeploymentState.Success); + var newStatus3 = new NewDeploymentStatus(DeploymentState.Success); + await _deploymentsClient.Status.Create(_context.Repository.Id, _deployment.Id, newStatus1); + await _deploymentsClient.Status.Create(_context.Repository.Id, _deployment.Id, newStatus2); + await _deploymentsClient.Status.Create(_context.Repository.Id, _deployment.Id, newStatus3); + + var startOptions = new ApiOptions + { + PageSize = 1, + PageCount = 1 + }; + + var firstPage = await _deploymentsClient.Status.GetAll(_context.Repository.Id, _deployment.Id, startOptions); + + var skipStartOptions = new ApiOptions + { + PageSize = 1, + PageCount = 1, + StartPage = 2 + }; + + var secondPage = await _deploymentsClient.Status.GetAll(_context.Repository.Id, _deployment.Id, skipStartOptions); + + Assert.NotEqual(firstPage[0].Id, secondPage[0].Id); + } + public void Dispose() { _context.Dispose();