updated deployment payload to support custom JSON

This commit is contained in:
Brendan Forster
2014-03-06 10:30:25 +11:00
parent e8326f610f
commit 8d1bda2172
4 changed files with 40 additions and 10 deletions
+14 -4
View File
@@ -1,4 +1,5 @@
using Octokit.Internal;
using System.Linq;
using Octokit.Internal;
using System;
using System.Collections.Generic;
using Xunit;
@@ -15,7 +16,7 @@ namespace Octokit.Tests.Models
Id = 1,
Url = "https://api.github.com/repos/octocat/example/deployments/1/statuses/42",
State = DeploymentState.Success,
Payload = "{\"environment\":\"production\"}",
Payload = new Dictionary<string, string> { { "environment", "production" } },
TargetUrl = "https://gist.github.com/628b2736d379f",
CreatedAt = DateTimeOffset.Parse("2012-07-20T01:19:13Z"),
UpdatedAt = DateTimeOffset.Parse("2012-07-20T01:19:13Z"),
@@ -46,7 +47,7 @@ namespace Octokit.Tests.Models
""type"": ""User"",
""site_admin"": false
},
""payload"": ""{\""environment\"":\""production\""}"",
""payload"": { ""environment"":""production""},
""target_url"": ""https://gist.github.com/628b2736d379f"",
""created_at"": ""2012-07-20T01:19:13Z"",
""updated_at"": ""2012-07-20T01:19:13Z"",
@@ -68,10 +69,19 @@ namespace Octokit.Tests.Models
if (x == null || y == null)
return false;
if (x.Payload.Keys.Any(key => x.Payload[key] != y.Payload[key]))
{
return false;
}
if (y.Payload.Keys.Any(key => x.Payload[key] != y.Payload[key]))
{
return false;
}
return x.Id == y.Id &&
x.Url == y.Url &&
x.State == y.State &&
x.Payload == y.Payload &&
x.TargetUrl == y.TargetUrl &&
x.CreatedAt == y.CreatedAt &&
x.UpdatedAt == y.UpdatedAt &&
+14 -4
View File
@@ -1,4 +1,5 @@
using Octokit.Internal;
using System.Linq;
using Octokit.Internal;
using System;
using System.Collections.Generic;
using Xunit;
@@ -14,7 +15,7 @@ namespace Octokit.Tests.Models
Id = 1,
Sha = "topic-branch",
Url = "https://api.github.com/repos/octocat/example/deployments/1",
Payload = "{\"environment\":\"production\"}",
Payload = new Dictionary<string, string>{{ "environment", "production"}},
CreatedAt = DateTimeOffset.Parse("2012-07-20T01:19:13Z"),
UpdatedAt = DateTimeOffset.Parse("2012-07-20T01:19:13Z"),
Description = "Deploy request from hubot",
@@ -45,7 +46,7 @@ namespace Octokit.Tests.Models
""type"": ""User"",
""site_admin"": false
},
""payload"": ""{\""environment\"":\""production\""}"",
""payload"": { ""environment"":""production""},
""created_at"": ""2012-07-20T01:19:13Z"",
""updated_at"": ""2012-07-20T01:19:13Z"",
""description"": ""Deploy request from hubot"",
@@ -71,10 +72,19 @@ namespace Octokit.Tests.Models
if (x == null || y == null)
return false;
if (x.Payload.Keys.Any(key => x.Payload[key] != y.Payload[key]))
{
return false;
}
if (y.Payload.Keys.Any(key => x.Payload[key] != y.Payload[key]))
{
return false;
}
return x.Id == y.Id &&
x.Sha == y .Sha &&
x.Url == y.Url &&
x.Payload == y.Payload &&
x.CreatedAt == y.CreatedAt &&
x.UpdatedAt == y.UpdatedAt &&
x.Description == y.Description &&
+3 -1
View File
@@ -1,4 +1,5 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Diagnostics.CodeAnalysis;
using System.Globalization;
@@ -33,7 +34,8 @@ namespace Octokit
/// <summary>
/// JSON payload with extra information about the deployment.
/// </summary>
public object Payload { get; set; }
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly")]
public IDictionary<string, string> Payload { get; set; }
/// <summary>
/// Date and time that the deployment was created.
+9 -1
View File
@@ -1,4 +1,6 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
@@ -7,6 +9,11 @@ namespace Octokit
[DebuggerDisplay("{DebuggerDisplay,nq}")]
public class DeploymentStatus
{
public DeploymentStatus()
{
Payload = new Dictionary<string, string>();
}
/// <summary>
/// Id of this deployment status.
/// </summary>
@@ -30,7 +37,8 @@ namespace Octokit
/// <summary>
/// JSON payload with extra information about the deployment.
/// </summary>
public object Payload { get; set; }
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly")]
public IDictionary<string,string> Payload { get; set; }
/// <summary>
/// The target URL of this deployment status. This URL should contain