diff --git a/Octokit.Tests.Conventions/Octokit.Tests.Conventions.csproj b/Octokit.Tests.Conventions/Octokit.Tests.Conventions.csproj index 45889e08bf..7b0589b97c 100644 --- a/Octokit.Tests.Conventions/Octokit.Tests.Conventions.csproj +++ b/Octokit.Tests.Conventions/Octokit.Tests.Conventions.csproj @@ -4,7 +4,7 @@ Convention-based tests for Octokit Octokit.Tests.Conventions GitHub - netcoreapp3.1;net462 + net6.0;netcoreapp3.1;net462 $(NoWarn);CS4014;CS1998 Octokit.Tests.Conventions Octokit.Tests.Conventions diff --git a/Octokit.Tests.Integration/Octokit.Tests.Integration.csproj b/Octokit.Tests.Integration/Octokit.Tests.Integration.csproj index ac2ff55db3..ae37077f7a 100644 --- a/Octokit.Tests.Integration/Octokit.Tests.Integration.csproj +++ b/Octokit.Tests.Integration/Octokit.Tests.Integration.csproj @@ -4,7 +4,7 @@ Integration tests for Octokit Octokit.Tests.Integration GitHub - netcoreapp3.1;net462 + net6.0;netcoreapp3.1;net462 $(NoWarn);CS4014;CS1998 Octokit.Tests.Integration Octokit.Tests.Integration diff --git a/Octokit.Tests/Models/DeploymentTests.cs b/Octokit.Tests/Models/DeploymentTests.cs index b1630152de..152bb8d2a5 100644 --- a/Octokit.Tests/Models/DeploymentTests.cs +++ b/Octokit.Tests/Models/DeploymentTests.cs @@ -1,6 +1,7 @@ using System; using System.Collections.Generic; using System.Collections.ObjectModel; +using System.Security.Policy; using Octokit.Internal; using Xunit; @@ -13,10 +14,10 @@ public void CanSerialize() { var deployment = new NewDeployment("ref") { - Payload = new Dictionary {{"environment", "production"}} + Payload = new Dictionary { { "environment", "production" } } }; var deserialized = new SimpleJsonSerializer().Serialize(deployment); - + Assert.Equal(@"{""ref"":""ref"",""payload"":{""environment"":""production""}}", deserialized); } @@ -24,14 +25,22 @@ public void CanSerialize() public void CanDeserialize() { const string json = @"{ - ""id"": 1, - ""sha"": ""topic-branch"", ""url"": ""https://api.github.com/repos/octocat/example/deployments/1"", + ""id"": 1, + ""node_id"": ""MDEwOkRlcGxveW1lbnQx"", + ""sha"": ""a84d88e7554fc1fa21bcbc4efae3c782a70d2b9d"", + ""ref"": ""topic-branch"", + ""task"": ""deploy"", + ""payload"": {}, + ""original_environment"": ""staging"", + ""environment"": ""production"", + ""description"": ""Deploy request from hubot"", ""creator"": { ""login"": ""octocat"", ""id"": 1, + ""node_id"": ""MDQ6VXNlcjE="", ""avatar_url"": ""https://github.com/images/error/octocat_happy.gif"", - ""gravatar_id"": ""somehexcode"", + ""gravatar_id"": """", ""url"": ""https://api.github.com/users/octocat"", ""html_url"": ""https://github.com/octocat"", ""followers_url"": ""https://api.github.com/users/octocat/followers"", @@ -46,24 +55,27 @@ public void CanDeserialize() ""type"": ""User"", ""site_admin"": false }, - ""payload"": { ""environment"":""production""}, ""created_at"": ""2012-07-20T01:19:13Z"", ""updated_at"": ""2012-07-20T01:19:13Z"", - ""description"": ""Deploy request from hubot"", ""statuses_url"": ""https://api.github.com/repos/octocat/example/deployments/1/statuses"", - ""task"": ""deploy"" + ""repository_url"": ""https://api.github.com/repos/octocat/example"", + ""transient_environment"": false, + ""production_environment"": true }"; var actual = new SimpleJsonSerializer().Deserialize(json); Assert.Equal(1, actual.Id); - Assert.Equal("topic-branch", actual.Sha); + Assert.Equal("a84d88e7554fc1fa21bcbc4efae3c782a70d2b9d", actual.Sha); + Assert.Equal("topic-branch", actual.Ref); Assert.Equal("https://api.github.com/repos/octocat/example/deployments/1", actual.Url); - Assert.Equal(new ReadOnlyDictionary(new Dictionary { { "environment", "production" } }), actual.Payload); + Assert.Equal("production", actual.Environment); + Assert.Equal("staging", actual.OriginalEnvironment); Assert.Equal(DateTimeOffset.Parse("2012-07-20T01:19:13Z"), actual.CreatedAt); Assert.Equal(DateTimeOffset.Parse("2012-07-20T01:19:13Z"), actual.UpdatedAt); Assert.Equal("Deploy request from hubot", actual.Description); Assert.Equal("https://api.github.com/repos/octocat/example/deployments/1/statuses", actual.StatusesUrl); + Assert.Equal("https://api.github.com/repos/octocat/example", actual.RepositoryUrl); Assert.Equal("deploy", actual.Task); } } diff --git a/Octokit.Tests/Octokit.Tests.csproj b/Octokit.Tests/Octokit.Tests.csproj index 9ec8a43959..30f7d910f7 100644 --- a/Octokit.Tests/Octokit.Tests.csproj +++ b/Octokit.Tests/Octokit.Tests.csproj @@ -4,7 +4,7 @@ Tests for Octokit Octokit.Tests GitHub - netcoreapp3.1;net462 + net6.0;netcoreapp3.1;net462 $(NoWarn);CS4014;CS1998 Octokit.Tests Octokit.Tests diff --git a/Octokit/Models/Response/Deployment.cs b/Octokit/Models/Response/Deployment.cs index f8dbb4cce3..00774d4abe 100644 --- a/Octokit/Models/Response/Deployment.cs +++ b/Octokit/Models/Response/Deployment.cs @@ -13,11 +13,12 @@ public class Deployment { public Deployment() { } - public Deployment(int id, string nodeId, string sha, string url, User creator, IReadOnlyDictionary payload, DateTimeOffset createdAt, DateTimeOffset updatedAt, string description, string statusesUrl, bool transientEnvironment, bool productionEnvironment, string task) + public Deployment(int id, string nodeId, string sha, string @ref, string url, User creator, IReadOnlyDictionary payload, DateTimeOffset createdAt, DateTimeOffset updatedAt, string description, string statusesUrl, string repositoryUrl, string environment, string originalEnvironment, bool transientEnvironment, bool productionEnvironment, string task) { Id = id; NodeId = nodeId; Sha = sha; + Ref = @ref; Url = url; Creator = creator; Payload = payload; @@ -25,6 +26,9 @@ public Deployment(int id, string nodeId, string sha, string url, User creator, I UpdatedAt = updatedAt; Description = description; StatusesUrl = statusesUrl; + RepositoryUrl = repositoryUrl; + Environment = environment; + OriginalEnvironment = originalEnvironment; TransientEnvironment = transientEnvironment; ProductionEnvironment = productionEnvironment; Task = task; @@ -41,10 +45,15 @@ public Deployment(int id, string nodeId, string sha, string url, User creator, I public string NodeId { get; private set; } /// - /// + /// The SHA recorded at creation time. /// public string Sha { get; private set; } + /// + /// The name of the ref. This can be a branch, tag, or SHA. + /// + public string Ref { get; private set; } + /// /// The API URL for this deployment. /// @@ -80,6 +89,21 @@ public Deployment(int id, string nodeId, string sha, string url, User creator, I /// public string StatusesUrl { get; private set; } + /// + /// The API URL for the of this deployment. + /// + public string RepositoryUrl { get; private set; } + + /// + /// The name of the that was deployed to (e.g., staging or production). + /// + public string Environment { get; private set; } + + /// + /// The name of the that was originally deployed to (e.g., staging or production). + /// + public string OriginalEnvironment { get; private set; } + /// /// Indicates if the environment is specific to a deployment and will no longer exist at some point in the future. ///