mirror of
https://github.com/zoriya/octokit.net.git
synced 2025-12-06 07:16:09 +00:00
some tidy up before cutting the release (#2201)
This commit is contained in:
11
.vscode/launch.json
vendored
11
.vscode/launch.json
vendored
@@ -23,6 +23,17 @@
|
|||||||
"console": "internalConsole",
|
"console": "internalConsole",
|
||||||
"stopAtEntry": false
|
"stopAtEntry": false
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"name": "Run integration tests",
|
||||||
|
"type": "coreclr",
|
||||||
|
"request": "launch",
|
||||||
|
"preLaunchTask": "build",
|
||||||
|
"program": "${workspaceFolder}/Octokit.Tests.Integration/bin/Debug/netcoreapp3.1/Octokit.Tests.Integration.dll",
|
||||||
|
"args": [],
|
||||||
|
"cwd": "${workspaceFolder}/Octokit.Tests.Integration",
|
||||||
|
"console": "internalConsole",
|
||||||
|
"stopAtEntry": false
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name": "Attach to process",
|
"name": "Attach to process",
|
||||||
"type": "coreclr",
|
"type": "coreclr",
|
||||||
|
|||||||
@@ -143,6 +143,6 @@ namespace Octokit.Reactive
|
|||||||
|
|
||||||
return _client.Update(org, updateRequest).ToObservable();
|
return _client.Update(org, updateRequest).ToObservable();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ namespace Octokit.Tests.Integration.Clients
|
|||||||
{
|
{
|
||||||
var github = Helper.GetAuthenticatedClient();
|
var github = Helper.GetAuthenticatedClient();
|
||||||
|
|
||||||
var hooks = await github.Organization.Hook.GetAll( _fixture.org);
|
var hooks = await github.Organization.Hook.GetAll(_fixture.org);
|
||||||
|
|
||||||
Assert.Equal(_fixture.ExpectedHooks.Count, hooks.Count);
|
Assert.Equal(_fixture.ExpectedHooks.Count, hooks.Count);
|
||||||
|
|
||||||
@@ -148,24 +148,23 @@ namespace Octokit.Tests.Integration.Clients
|
|||||||
Assert.Equal(new[] { "push" }.ToList(), hook.Events.ToList());
|
Assert.Equal(new[] { "push" }.ToList(), hook.Events.ToList());
|
||||||
Assert.Equal(baseHookUrl, hook.Url);
|
Assert.Equal(baseHookUrl, hook.Url);
|
||||||
Assert.Equal(baseHookUrl + "/pings", hook.PingUrl);
|
Assert.Equal(baseHookUrl + "/pings", hook.PingUrl);
|
||||||
Assert.NotNull(hook.CreatedAt);
|
Assert.NotEqual(default, hook.CreatedAt);
|
||||||
Assert.NotNull(hook.UpdatedAt);
|
Assert.NotEqual(default, hook.UpdatedAt);
|
||||||
Assert.Equal(webHookConfig.Keys, hook.Config.Keys);
|
Assert.Equal(webHookConfig.Keys, hook.Config.Keys);
|
||||||
//Assert.Equal(webHookConfig.Values, hook.Config.Values);
|
Assert.False(hook.Active);
|
||||||
Assert.Equal(false, hook.Active);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Dictionary<string, string> CreateExpectedConfigDictionary(Dictionary<string, string> config, string url, OrgWebHookContentType contentType)
|
Dictionary<string, string> CreateExpectedConfigDictionary(Dictionary<string, string> config, string url, OrgWebHookContentType contentType)
|
||||||
{
|
{
|
||||||
return new Dictionary<string, string>
|
return new Dictionary<string, string>
|
||||||
{
|
{
|
||||||
|
|
||||||
}.Union(config).ToDictionary(k => k.Key, v => v.Value);
|
}.Union(config).ToDictionary(k => k.Key, v => v.Value);
|
||||||
}
|
}
|
||||||
|
|
||||||
string CreateExpectedBaseHookUrl(string org, int id)
|
string CreateExpectedBaseHookUrl(string org, int id)
|
||||||
{
|
{
|
||||||
return "https://api.github.com/orgs/" + org+ "/hooks/" + id;
|
return "https://api.github.com/orgs/" + org + "/hooks/" + id;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -189,7 +188,7 @@ namespace Octokit.Tests.Integration.Clients
|
|||||||
Events = new[] { "pull_request" }
|
Events = new[] { "pull_request" }
|
||||||
};
|
};
|
||||||
|
|
||||||
var actualHook = await github.Organization.Hook.Edit( _fixture.org, _fixture.ExpectedHook.Id, editOrganizationHook);
|
var actualHook = await github.Organization.Hook.Edit(_fixture.org, _fixture.ExpectedHook.Id, editOrganizationHook);
|
||||||
|
|
||||||
var expectedConfig = new Dictionary<string, string> { { "content_type", "json" }, { "url", "http://test.com/example" } };
|
var expectedConfig = new Dictionary<string, string> { { "content_type", "json" }, { "url", "http://test.com/example" } };
|
||||||
Assert.Equal(new[] { "commit_comment", "pull_request" }.ToList(), actualHook.Events.ToList());
|
Assert.Equal(new[] { "commit_comment", "pull_request" }.ToList(), actualHook.Events.ToList());
|
||||||
@@ -213,7 +212,7 @@ namespace Octokit.Tests.Integration.Clients
|
|||||||
{
|
{
|
||||||
var github = Helper.GetAuthenticatedClient();
|
var github = Helper.GetAuthenticatedClient();
|
||||||
|
|
||||||
await github.Organization.Hook.Ping( _fixture.org, _fixture.ExpectedHook.Id);
|
await github.Organization.Hook.Ping(_fixture.org, _fixture.ExpectedHook.Id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -233,7 +232,7 @@ namespace Octokit.Tests.Integration.Clients
|
|||||||
var github = Helper.GetAuthenticatedClient();
|
var github = Helper.GetAuthenticatedClient();
|
||||||
|
|
||||||
await github.Organization.Hook.Delete(_fixture.org, _fixture.ExpectedHook.Id);
|
await github.Organization.Hook.Delete(_fixture.org, _fixture.ExpectedHook.Id);
|
||||||
var hooks = await github.Organization.Hook.GetAll( _fixture.org);
|
var hooks = await github.Organization.Hook.GetAll(_fixture.org);
|
||||||
|
|
||||||
Assert.Empty(hooks);
|
Assert.Empty(hooks);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ namespace Octokit.Tests.Integration.Fixtures
|
|||||||
|
|
||||||
public void Dispose()
|
public void Dispose()
|
||||||
{
|
{
|
||||||
_github.Organization.Hook.Delete(_organizationFixture,_hook.Id);
|
_github.Organization.Hook.Delete(_organizationFixture, _hook.Id);
|
||||||
}
|
}
|
||||||
|
|
||||||
static OrganizationHook CreateHook(IGitHubClient github, string orgFixture, string hookName, string eventName)
|
static OrganizationHook CreateHook(IGitHubClient github, string orgFixture, string hookName, string eventName)
|
||||||
|
|||||||
@@ -94,7 +94,7 @@ namespace Octokit.Tests.Clients
|
|||||||
{
|
{
|
||||||
var client = new OrganizationsClient(Substitute.For<IApiConnection>());
|
var client = new OrganizationsClient(Substitute.For<IApiConnection>());
|
||||||
|
|
||||||
await Assert.ThrowsAsync<ArgumentException>(() => client.Hook.Get("",123));
|
await Assert.ThrowsAsync<ArgumentException>(() => client.Hook.Get("", 123));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -162,8 +162,8 @@ namespace Octokit.Tests.Clients
|
|||||||
{
|
{
|
||||||
var client = new OrganizationsClient(Substitute.For<IApiConnection>());
|
var client = new OrganizationsClient(Substitute.For<IApiConnection>());
|
||||||
|
|
||||||
await Assert.ThrowsAsync<ArgumentNullException>(() => client.Hook.Edit( null, 12345678, new EditOrganizationHook()));
|
await Assert.ThrowsAsync<ArgumentNullException>(() => client.Hook.Edit(null, 12345678, new EditOrganizationHook()));
|
||||||
await Assert.ThrowsAsync<ArgumentNullException>(() => client.Hook.Edit( "name", 12345678, null));
|
await Assert.ThrowsAsync<ArgumentNullException>(() => client.Hook.Edit("name", 12345678, null));
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
|
|||||||
@@ -11,23 +11,23 @@ namespace Octokit.Tests.Models
|
|||||||
public void UsesDefaultValuesForDefaultConfig()
|
public void UsesDefaultValuesForDefaultConfig()
|
||||||
{
|
{
|
||||||
var create = new NewOrganizationWebHook("windowsazure", new Dictionary<string, string>(), "http://test.com/example");
|
var create = new NewOrganizationWebHook("windowsazure", new Dictionary<string, string>(), "http://test.com/example");
|
||||||
Assert.Equal(create.Url, "http://test.com/example");
|
Assert.Equal("http://test.com/example", create.Url);
|
||||||
Assert.Equal(create.ContentType, OrgWebHookContentType.Form);
|
Assert.Equal(OrgWebHookContentType.Form, create.ContentType);
|
||||||
Assert.Empty(create.Secret);
|
Assert.Empty(create.Secret);
|
||||||
Assert.False(create.InsecureSsl);
|
Assert.False(create.InsecureSsl);
|
||||||
|
|
||||||
var request = create.ToRequest();
|
var request = create.ToRequest();
|
||||||
Assert.Equal(request.Config.Count, 4);
|
Assert.Equal(4, request.Config.Count);
|
||||||
|
|
||||||
Assert.True(request.Config.ContainsKey("url"));
|
Assert.True(request.Config.ContainsKey("url"));
|
||||||
Assert.True(request.Config.ContainsKey("content_type"));
|
Assert.True(request.Config.ContainsKey("content_type"));
|
||||||
Assert.True(request.Config.ContainsKey("secret"));
|
Assert.True(request.Config.ContainsKey("secret"));
|
||||||
Assert.True(request.Config.ContainsKey("insecure_ssl"));
|
Assert.True(request.Config.ContainsKey("insecure_ssl"));
|
||||||
|
|
||||||
Assert.Equal(request.Config["url"], "http://test.com/example");
|
Assert.Equal("http://test.com/example", request.Config["url"]);
|
||||||
Assert.Equal(request.Config["content_type"], OrgWebHookContentType.Form.ToParameter());
|
Assert.Equal(request.Config["content_type"], OrgWebHookContentType.Form.ToParameter());
|
||||||
Assert.Equal(request.Config["secret"], "");
|
Assert.Equal("", request.Config["secret"]);
|
||||||
Assert.Equal(request.Config["insecure_ssl"], "False");
|
Assert.Equal("False", request.Config["insecure_ssl"]);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
@@ -47,24 +47,24 @@ namespace Octokit.Tests.Models
|
|||||||
InsecureSsl = true
|
InsecureSsl = true
|
||||||
};
|
};
|
||||||
|
|
||||||
Assert.Equal(create.Url, "http://test.com/example");
|
Assert.Equal("http://test.com/example", create.Url);
|
||||||
Assert.Equal(create.ContentType, OrgWebHookContentType.Json);
|
Assert.Equal(OrgWebHookContentType.Json, create.ContentType);
|
||||||
Assert.Empty(create.Secret);
|
Assert.Empty(create.Secret);
|
||||||
Assert.True(create.InsecureSsl);
|
Assert.True(create.InsecureSsl);
|
||||||
|
|
||||||
var request = create.ToRequest();
|
var request = create.ToRequest();
|
||||||
|
|
||||||
Assert.Equal(request.Config.Count, 7);
|
Assert.Equal(7, request.Config.Count);
|
||||||
|
|
||||||
Assert.True(request.Config.ContainsKey("url"));
|
Assert.True(request.Config.ContainsKey("url"));
|
||||||
Assert.True(request.Config.ContainsKey("content_type"));
|
Assert.True(request.Config.ContainsKey("content_type"));
|
||||||
Assert.True(request.Config.ContainsKey("secret"));
|
Assert.True(request.Config.ContainsKey("secret"));
|
||||||
Assert.True(request.Config.ContainsKey("insecure_ssl"));
|
Assert.True(request.Config.ContainsKey("insecure_ssl"));
|
||||||
|
|
||||||
Assert.Equal(request.Config["url"], "http://test.com/example");
|
Assert.Equal("http://test.com/example", request.Config["url"]);
|
||||||
Assert.Equal(request.Config["content_type"], OrgWebHookContentType.Json.ToParameter());
|
Assert.Equal(request.Config["content_type"], OrgWebHookContentType.Json.ToParameter());
|
||||||
Assert.Equal(request.Config["secret"], "");
|
Assert.Equal("", request.Config["secret"]);
|
||||||
Assert.Equal(request.Config["insecure_ssl"], true.ToString());
|
Assert.Equal("True", request.Config["insecure_ssl"]);
|
||||||
|
|
||||||
Assert.True(request.Config.ContainsKey("hostname"));
|
Assert.True(request.Config.ContainsKey("hostname"));
|
||||||
Assert.Equal(request.Config["hostname"], config["hostname"]);
|
Assert.Equal(request.Config["hostname"], config["hostname"]);
|
||||||
@@ -110,8 +110,8 @@ namespace Octokit.Tests.Models
|
|||||||
var request = create.ToRequest();
|
var request = create.ToRequest();
|
||||||
var requestRepeated = create.ToRequest();
|
var requestRepeated = create.ToRequest();
|
||||||
|
|
||||||
Assert.Equal(request.Config.Count, 4);
|
Assert.Equal(4, request.Config.Count);
|
||||||
Assert.Equal(requestRepeated.Config.Count, 4);
|
Assert.Equal(4, requestRepeated.Config.Count);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
@@ -131,8 +131,8 @@ namespace Octokit.Tests.Models
|
|||||||
var requestRepeated = create.ToRequest();
|
var requestRepeated = create.ToRequest();
|
||||||
|
|
||||||
//This is not 8, because `url` used in config, is already part of the base config
|
//This is not 8, because `url` used in config, is already part of the base config
|
||||||
Assert.Equal(request.Config.Count, 7);
|
Assert.Equal(7, request.Config.Count);
|
||||||
Assert.Equal(requestRepeated.Config.Count, 7);
|
Assert.Equal(7, requestRepeated.Config.Count);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
@@ -147,10 +147,10 @@ namespace Octokit.Tests.Models
|
|||||||
|
|
||||||
var request = create.ToRequest();
|
var request = create.ToRequest();
|
||||||
|
|
||||||
Assert.Equal(request.Config["url"], "http://test.com/example");
|
Assert.Equal("http://test.com/example", request.Config["url"]);
|
||||||
|
|
||||||
var subsequentRequest = create.ToRequest();
|
var subsequentRequest = create.ToRequest();
|
||||||
Assert.Equal(subsequentRequest.Config["url"], "http://test.com/example");
|
Assert.Equal("http://test.com/example", subsequentRequest.Config["url"]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1016,7 +1016,7 @@ namespace Octokit
|
|||||||
{
|
{
|
||||||
return "orgs/{0}/hooks/{1}/pings".FormatUri(org, hookId);
|
return "orgs/{0}/hooks/{1}/pings".FormatUri(org, hookId);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Returns the <see cref="Uri"/> that lists the commit statuses for the specified reference.
|
/// Returns the <see cref="Uri"/> that lists the commit statuses for the specified reference.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
Reference in New Issue
Block a user