Skip to content

Commit

Permalink
some tidy up before cutting the release (#2201)
Browse files Browse the repository at this point in the history
  • Loading branch information
shiftkey authored Jun 7, 2020
1 parent af74ae8 commit d02a230
Show file tree
Hide file tree
Showing 7 changed files with 44 additions and 34 deletions.
11 changes: 11 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,17 @@
"console": "internalConsole",
"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",
"type": "coreclr",
Expand Down
2 changes: 1 addition & 1 deletion Octokit.Reactive/Clients/ObservableOrganizationsClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,6 @@ public IObservable<Organization> Update(string org, OrganizationUpdate updateReq

return _client.Update(org, updateRequest).ToObservable();
}

}
}
19 changes: 9 additions & 10 deletions Octokit.Tests.Integration/Clients/OrganizationHooksClientTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public async Task ReturnsAllHooksFromOrganization()
{
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);

Expand Down Expand Up @@ -148,24 +148,23 @@ public async Task CreateAWebHookForTestOrganization()
Assert.Equal(new[] { "push" }.ToList(), hook.Events.ToList());
Assert.Equal(baseHookUrl, hook.Url);
Assert.Equal(baseHookUrl + "/pings", hook.PingUrl);
Assert.NotNull(hook.CreatedAt);
Assert.NotNull(hook.UpdatedAt);
Assert.NotEqual(default, hook.CreatedAt);
Assert.NotEqual(default, hook.UpdatedAt);
Assert.Equal(webHookConfig.Keys, hook.Config.Keys);
//Assert.Equal(webHookConfig.Values, hook.Config.Values);
Assert.Equal(false, hook.Active);
Assert.False(hook.Active);
}

Dictionary<string, string> CreateExpectedConfigDictionary(Dictionary<string, string> config, string url, OrgWebHookContentType contentType)
{
return new Dictionary<string, string>
{

}.Union(config).ToDictionary(k => k.Key, v => v.Value);
}

string CreateExpectedBaseHookUrl(string org, int id)
{
return "https://api.github.com/orgs/" + org+ "/hooks/" + id;
return "https://api.github.com/orgs/" + org + "/hooks/" + id;
}
}

Expand All @@ -189,7 +188,7 @@ public async Task EditHookTest()
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" } };
Assert.Equal(new[] { "commit_comment", "pull_request" }.ToList(), actualHook.Events.ToList());
Expand All @@ -213,7 +212,7 @@ public async Task PingACreatedHook()
{
var github = Helper.GetAuthenticatedClient();

await github.Organization.Hook.Ping( _fixture.org, _fixture.ExpectedHook.Id);
await github.Organization.Hook.Ping(_fixture.org, _fixture.ExpectedHook.Id);
}
}

Expand All @@ -233,7 +232,7 @@ public async Task DeleteCreatedWebHook()
var github = Helper.GetAuthenticatedClient();

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);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public OrganizationsHooksFixture()

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)
Expand Down
6 changes: 3 additions & 3 deletions Octokit.Tests/Clients/OrganizationHooksClientTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ public async Task EnsuresNonEmptyArguments()
{
var client = new OrganizationsClient(Substitute.For<IApiConnection>());

await Assert.ThrowsAsync<ArgumentException>(() => client.Hook.Get("",123));
await Assert.ThrowsAsync<ArgumentException>(() => client.Hook.Get("", 123));
}
}

Expand Down Expand Up @@ -162,8 +162,8 @@ public async Task EnsuresNonNullArguments()
{
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( "name", 12345678, null));
await Assert.ThrowsAsync<ArgumentNullException>(() => client.Hook.Edit(null, 12345678, new EditOrganizationHook()));
await Assert.ThrowsAsync<ArgumentNullException>(() => client.Hook.Edit("name", 12345678, null));
}

[Fact]
Expand Down
36 changes: 18 additions & 18 deletions Octokit.Tests/Models/NewOrganizationWebHookTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,23 +11,23 @@ public class TheCtor
public void UsesDefaultValuesForDefaultConfig()
{
var create = new NewOrganizationWebHook("windowsazure", new Dictionary<string, string>(), "http://test.com/example");
Assert.Equal(create.Url, "http://test.com/example");
Assert.Equal(create.ContentType, OrgWebHookContentType.Form);
Assert.Equal("http://test.com/example", create.Url);
Assert.Equal(OrgWebHookContentType.Form, create.ContentType);
Assert.Empty(create.Secret);
Assert.False(create.InsecureSsl);

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("content_type"));
Assert.True(request.Config.ContainsKey("secret"));
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["secret"], "");
Assert.Equal(request.Config["insecure_ssl"], "False");
Assert.Equal("", request.Config["secret"]);
Assert.Equal("False", request.Config["insecure_ssl"]);
}

[Fact]
Expand All @@ -47,24 +47,24 @@ public void CombinesUserSpecifiedContentTypeWithConfig()
InsecureSsl = true
};

Assert.Equal(create.Url, "http://test.com/example");
Assert.Equal(create.ContentType, OrgWebHookContentType.Json);
Assert.Equal("http://test.com/example", create.Url);
Assert.Equal(OrgWebHookContentType.Json, create.ContentType);
Assert.Empty(create.Secret);
Assert.True(create.InsecureSsl);

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("content_type"));
Assert.True(request.Config.ContainsKey("secret"));
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["secret"], "");
Assert.Equal(request.Config["insecure_ssl"], true.ToString());
Assert.Equal("", request.Config["secret"]);
Assert.Equal("True", request.Config["insecure_ssl"]);

Assert.True(request.Config.ContainsKey("hostname"));
Assert.Equal(request.Config["hostname"], config["hostname"]);
Expand Down Expand Up @@ -110,8 +110,8 @@ public void ShouldNotContainDuplicateConfigEntriesOnSubsequentRequests()
var request = create.ToRequest();
var requestRepeated = create.ToRequest();

Assert.Equal(request.Config.Count, 4);
Assert.Equal(requestRepeated.Config.Count, 4);
Assert.Equal(4, request.Config.Count);
Assert.Equal(4, requestRepeated.Config.Count);
}

[Fact]
Expand All @@ -131,8 +131,8 @@ public void ShouldNotContainDuplicateConfigEntriesOnSubsequentRequestsWithCustom
var requestRepeated = create.ToRequest();

//This is not 8, because `url` used in config, is already part of the base config
Assert.Equal(request.Config.Count, 7);
Assert.Equal(requestRepeated.Config.Count, 7);
Assert.Equal(7, request.Config.Count);
Assert.Equal(7, requestRepeated.Config.Count);
}

[Fact]
Expand All @@ -147,10 +147,10 @@ public void PropertiesShouldTakePrecedenceOverConfigPassedIn()

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();
Assert.Equal(subsequentRequest.Config["url"], "http://test.com/example");
Assert.Equal("http://test.com/example", subsequentRequest.Config["url"]);
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion Octokit/Helpers/ApiUrls.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1016,7 +1016,7 @@ public static Uri OrganizationHookPing(string org, int hookId)
{
return "orgs/{0}/hooks/{1}/pings".FormatUri(org, hookId);
}

/// <summary>
/// Returns the <see cref="Uri"/> that lists the commit statuses for the specified reference.
/// </summary>
Expand Down

0 comments on commit d02a230

Please sign in to comment.