mirror of
https://github.com/zoriya/octokit.net.git
synced 2026-06-08 04:40:54 +00:00
Implement Deployment Statuses Preview (#1895)
Co-authored-by: Brendan Forster <brendan@github.com>
This commit is contained in:
@@ -40,7 +40,10 @@ public class DeploymentStatusClientTests : IDisposable
|
||||
|
||||
var commit = github.Git.Commit.Create(_context.RepositoryOwner, _context.RepositoryName, newCommit).Result;
|
||||
|
||||
var newDeployment = new NewDeployment(commit.Sha) { AutoMerge = false };
|
||||
var newDeployment = new NewDeployment(commit.Sha) {
|
||||
Environment = "production",
|
||||
AutoMerge = false
|
||||
};
|
||||
_deployment = _deploymentsClient.Create(_context.RepositoryOwner, _context.RepositoryName, newDeployment).Result;
|
||||
}
|
||||
|
||||
@@ -55,6 +58,17 @@ public class DeploymentStatusClientTests : IDisposable
|
||||
Assert.Equal(DeploymentState.Success, status.State);
|
||||
}
|
||||
|
||||
[IntegrationTest]
|
||||
public async Task CanCreateDeploymentStatusWithNewState()
|
||||
{
|
||||
var newStatus = new NewDeploymentStatus(DeploymentState.InProgress);
|
||||
|
||||
var status = await _deploymentsClient.Status.Create(_context.RepositoryOwner, _context.RepositoryName, _deployment.Id, newStatus);
|
||||
|
||||
Assert.NotNull(status);
|
||||
Assert.Equal(DeploymentState.InProgress, status.State);
|
||||
}
|
||||
|
||||
[IntegrationTest]
|
||||
public async Task CanCreateDeploymentStatusWithRepositoryId()
|
||||
{
|
||||
@@ -243,4 +257,3 @@ public class DeploymentStatusClientTests : IDisposable
|
||||
_context.Dispose();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -21,7 +21,7 @@ public class DeploymentStatusClientTests
|
||||
connection.Received().GetAll<
|
||||
DeploymentStatus>(Arg.Is<Uri>(u => u.ToString() == expectedUrl),
|
||||
null,
|
||||
"application/vnd.github.ant-man-preview+json",
|
||||
"application/vnd.github.ant-man-preview+json,application/vnd.github.flash-preview+json",
|
||||
Args.ApiOptions);
|
||||
}
|
||||
|
||||
@@ -34,7 +34,10 @@ public class DeploymentStatusClientTests
|
||||
|
||||
await client.GetAll(1, 1);
|
||||
|
||||
connection.Received().GetAll<DeploymentStatus>(Arg.Is<Uri>(u => u.ToString() == expectedUrl), Args.ApiOptions);
|
||||
connection.Received().GetAll<DeploymentStatus>(Arg.Is<Uri>(u => u.ToString() == expectedUrl),
|
||||
null,
|
||||
"application/vnd.github.ant-man-preview+json,application/vnd.github.flash-preview+json",
|
||||
Args.ApiOptions);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@@ -56,7 +59,7 @@ public class DeploymentStatusClientTests
|
||||
connection.Received().GetAll<DeploymentStatus>(
|
||||
Arg.Is<Uri>(u => u.ToString() == expectedUrl),
|
||||
null,
|
||||
"application/vnd.github.ant-man-preview+json",
|
||||
"application/vnd.github.ant-man-preview+json,application/vnd.github.flash-preview+json",
|
||||
options);
|
||||
}
|
||||
|
||||
@@ -76,7 +79,10 @@ public class DeploymentStatusClientTests
|
||||
|
||||
await client.GetAll(1, 1, options);
|
||||
|
||||
connection.Received().GetAll<DeploymentStatus>(Arg.Is<Uri>(u => u.ToString() == expectedUrl), options);
|
||||
connection.Received().GetAll<DeploymentStatus>(Arg.Is<Uri>(u => u.ToString() == expectedUrl),
|
||||
null,
|
||||
"application/vnd.github.ant-man-preview+json,application/vnd.github.flash-preview+json",
|
||||
options);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@@ -132,7 +138,7 @@ public class DeploymentStatusClientTests
|
||||
|
||||
connection.Received().Post<DeploymentStatus>(Arg.Is<Uri>(u => u.ToString() == expectedUrl),
|
||||
newDeploymentStatus,
|
||||
"application/vnd.github.ant-man-preview+json");
|
||||
"application/vnd.github.ant-man-preview+json,application/vnd.github.flash-preview+json");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@@ -145,7 +151,8 @@ public class DeploymentStatusClientTests
|
||||
client.Create(1, 1, newDeploymentStatus);
|
||||
|
||||
connection.Received().Post<DeploymentStatus>(Arg.Is<Uri>(u => u.ToString() == expectedUrl),
|
||||
Arg.Any<NewDeploymentStatus>());
|
||||
Arg.Any<NewDeploymentStatus>(),
|
||||
"application/vnd.github.ant-man-preview+json,application/vnd.github.flash-preview+json");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@@ -202,7 +209,7 @@ public class DeploymentStatusClientTests
|
||||
|
||||
connection.Received(1).Post<DeploymentStatus>(Arg.Is<Uri>(u => u.ToString() == expectedUrl),
|
||||
Arg.Any<NewDeploymentStatus>(),
|
||||
Arg.Is<string>(s => s == AcceptHeaders.DeploymentApiPreview));
|
||||
Arg.Is<string>(s => s == "application/vnd.github.ant-man-preview+json,application/vnd.github.flash-preview+json"));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -68,7 +68,7 @@ namespace Octokit
|
||||
|
||||
return ApiConnection.GetAll<DeploymentStatus>(ApiUrls.DeploymentStatuses(owner, name, deploymentId),
|
||||
null,
|
||||
AcceptHeaders.DeploymentApiPreview,
|
||||
AcceptHeaders.Concat(AcceptHeaders.DeploymentApiPreview, AcceptHeaders.DeploymentStatusesPreview),
|
||||
options);
|
||||
}
|
||||
|
||||
@@ -86,7 +86,10 @@ namespace Octokit
|
||||
{
|
||||
Ensure.ArgumentNotNull(options, nameof(options));
|
||||
|
||||
return ApiConnection.GetAll<DeploymentStatus>(ApiUrls.DeploymentStatuses(repositoryId, deploymentId), options);
|
||||
return ApiConnection.GetAll<DeploymentStatus>(ApiUrls.DeploymentStatuses(repositoryId, deploymentId),
|
||||
null,
|
||||
AcceptHeaders.Concat(AcceptHeaders.DeploymentApiPreview, AcceptHeaders.DeploymentStatusesPreview),
|
||||
options);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -108,7 +111,7 @@ namespace Octokit
|
||||
|
||||
return ApiConnection.Post<DeploymentStatus>(ApiUrls.DeploymentStatuses(owner, name, deploymentId),
|
||||
newDeploymentStatus,
|
||||
AcceptHeaders.DeploymentApiPreview);
|
||||
AcceptHeaders.Concat(AcceptHeaders.DeploymentApiPreview, AcceptHeaders.DeploymentStatusesPreview));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -126,7 +129,8 @@ namespace Octokit
|
||||
Ensure.ArgumentNotNull(newDeploymentStatus, nameof(newDeploymentStatus));
|
||||
|
||||
return ApiConnection.Post<DeploymentStatus>(ApiUrls.DeploymentStatuses(repositoryId, deploymentId),
|
||||
newDeploymentStatus);
|
||||
newDeploymentStatus,
|
||||
AcceptHeaders.Concat(AcceptHeaders.DeploymentApiPreview, AcceptHeaders.DeploymentStatusesPreview));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -71,6 +71,8 @@ namespace Octokit
|
||||
|
||||
public const string IssueEventsApiPreview = "application/vnd.github.starfox-preview";
|
||||
|
||||
public const string DeploymentStatusesPreview = "application/vnd.github.flash-preview+json";
|
||||
|
||||
/// <summary>
|
||||
/// Combines multiple preview headers. GitHub API supports Accept header with multiple
|
||||
/// values separated by comma.
|
||||
|
||||
@@ -41,6 +41,11 @@ namespace Octokit
|
||||
/// </summary>
|
||||
public string EnvironmentUrl { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Name for the target deployment environment.
|
||||
/// </summary>
|
||||
public string Environment { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Indicates if a new inactive status should be added to all non-transient,
|
||||
/// non-production environment deployments with the same repository and environment
|
||||
|
||||
@@ -115,6 +115,12 @@ namespace Octokit
|
||||
Failure,
|
||||
|
||||
[Parameter(Value = "inactive")]
|
||||
Inactive
|
||||
Inactive,
|
||||
|
||||
[Parameter(Value = "in_progress")]
|
||||
InProgress,
|
||||
|
||||
[Parameter(Value = "queued")]
|
||||
Queued
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user