Skip to content

Commit

Permalink
Release v0.31 - Check yo' self! (#1851)
Browse files Browse the repository at this point in the history
* Fix whitespace/formatting with /FormatCode build option

* Update release notes

* fix a few failing integration tests

* Adjust required fields on UpdateCheckRun and NewCheckRun request models and fix tests
Tidy up field accessors and XmlDoc comments

* Update date in ReleaseNotes

* Keeping request models simple (avoid inheritance) - makes it easier when we move to generated models
  • Loading branch information
ryangribble authored Jul 21, 2018
1 parent c5d5df5 commit 1015220
Show file tree
Hide file tree
Showing 21 changed files with 173 additions and 83 deletions.
4 changes: 2 additions & 2 deletions Octokit.Reactive/Clients/ObservableRepositoriesClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ public IObservable<Unit> Delete(long repositoryId)
{
return _client.Delete(repositoryId).ToObservable();
}

/// <summary>
/// Transfers the ownership of the specified repository.
/// </summary>
Expand Down Expand Up @@ -127,7 +127,7 @@ public IObservable<Repository> Transfer(string owner, string name, RepositoryTra
public IObservable<Repository> Transfer(long repositoryId, RepositoryTransfer repositoryTransfer)
{
Ensure.ArgumentNotNull(repositoryTransfer, nameof(repositoryTransfer));

return _client.Transfer(repositoryId, repositoryTransfer).ToObservable();
}

Expand Down
6 changes: 4 additions & 2 deletions Octokit.Tests.Integration/Clients/CheckRunsClientTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,9 @@ public async Task UpdatesCheckRun()
var checkRun = await _githubAppInstallation.Check.Run.Create(repoContext.RepositoryOwner, repoContext.RepositoryName, newCheckRun);

// Update the check run
var update = new CheckRunUpdate("new-name")
var update = new CheckRunUpdate
{
Name = "new-name",
Status = CheckStatus.InProgress
};
var result = await _githubAppInstallation.Check.Run.Update(repoContext.RepositoryOwner, repoContext.RepositoryName, checkRun.Id, update);
Expand Down Expand Up @@ -127,8 +128,9 @@ public async Task UpdatesCheckRunWithRepositoryId()
var checkRun = await _githubAppInstallation.Check.Run.Create(repoContext.RepositoryId, newCheckRun);

// Update the check run
var update = new CheckRunUpdate("new-name")
var update = new CheckRunUpdate
{
Name = "new-name",
Status = CheckStatus.InProgress
};
var result = await _githubAppInstallation.Check.Run.Update(repoContext.RepositoryId, checkRun.Id, update);
Expand Down
16 changes: 9 additions & 7 deletions Octokit.Tests.Integration/Clients/RepositoriesClientTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1719,11 +1719,11 @@ public async Task TransfersFromOrgToUser()
var transfer = new RepositoryTransfer(newOwner);
await github.Repository.Transfer(context.RepositoryOwner, context.RepositoryName, transfer);
var transferred = await github.Repository.Get(newOwner, context.RepositoryName);

Assert.Equal(newOwner, transferred.Owner.Login);
}
}

[IntegrationTest]
public async Task TransfersFromOrgToUserById()
{
Expand Down Expand Up @@ -1751,11 +1751,11 @@ public async Task TransfersFromUserToOrg()
var transfer = new RepositoryTransfer(newOwner);
await github.Repository.Transfer(context.RepositoryOwner, context.RepositoryName, transfer);
var transferred = await github.Repository.Get(newOwner, context.RepositoryName);

Assert.Equal(newOwner, transferred.Owner.Login);
}
}

[IntegrationTest]
public async Task TransfersFromUserToOrgById()
{
Expand Down Expand Up @@ -1783,7 +1783,8 @@ public async Task TransfersFromUserToOrgWithTeams()
using (var repositoryContext = await github.CreateRepositoryContext(newRepo))
{
NewTeam team = new NewTeam(Helper.MakeNameWithTimestamp("transfer-team"));
using (var teamContext = await github.CreateTeamContext(Helper.Organization, team)) {
using (var teamContext = await github.CreateTeamContext(Helper.Organization, team))
{
var transferTeamIds = new int[] { teamContext.TeamId };
var transfer = new RepositoryTransfer(newOwner, transferTeamIds);
await github.Repository.Transfer(
Expand All @@ -1799,7 +1800,7 @@ await github.Repository.Transfer(
}
}
}

[IntegrationTest]
public async Task TransfersFromUserToOrgWithTeamsById()
{
Expand All @@ -1811,7 +1812,8 @@ public async Task TransfersFromUserToOrgWithTeamsById()
using (var repositoryContext = await github.CreateRepositoryContext(newRepo))
{
NewTeam team = new NewTeam(Helper.MakeNameWithTimestamp("transfer-team"));
using (var teamContext = await github.CreateTeamContext(Helper.Organization, team)) {
using (var teamContext = await github.CreateTeamContext(Helper.Organization, team))
{
var transferTeamIds = new int[] { teamContext.TeamId };
var transfer = new RepositoryTransfer(newOwner, transferTeamIds);
await github.Repository.Transfer(repositoryContext.RepositoryId, transfer);
Expand Down
24 changes: 12 additions & 12 deletions Octokit.Tests.Integration/Clients/RepositoryContentsClientTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ public async Task ReturnsReadmeForSeeGit()

var readme = await github.Repository.Content.GetReadme("octokit", "octokit.net");
Assert.Equal("README.md", readme.Name);
string readMeHtml = await readme.GetHtmlContent();
Assert.True(readMeHtml.StartsWith("<div class="));
Assert.Contains(@"data-path=""README.md"" id=""file""", readMeHtml);
Assert.Contains("Octokit - GitHub API Client Library for .NET", readMeHtml);
string readmeHtml = await readme.GetHtmlContent();
Assert.True(readmeHtml.StartsWith("<div id="));
Assert.Contains("data-path=\"README.md\"", readmeHtml);
Assert.Contains("Octokit - GitHub API Client Library for .NET", readmeHtml);
}

[IntegrationTest]
Expand All @@ -30,10 +30,10 @@ public async Task ReturnsReadmeForSeeGitWithRepositoryId()

var readme = await github.Repository.Content.GetReadme(7528679);
Assert.Equal("README.md", readme.Name);
string readMeHtml = await readme.GetHtmlContent();
Assert.True(readMeHtml.StartsWith("<div class="));
Assert.Contains(@"data-path=""README.md"" id=""file""", readMeHtml);
Assert.Contains("Octokit - GitHub API Client Library for .NET", readMeHtml);
string readmeHtml = await readme.GetHtmlContent();
Assert.True(readmeHtml.StartsWith("<div id="));
Assert.Contains("data-path=\"README.md\"", readmeHtml);
Assert.Contains("Octokit - GitHub API Client Library for .NET", readmeHtml);
}

[IntegrationTest]
Expand All @@ -42,8 +42,8 @@ public async Task ReturnsReadmeHtmlForSeeGit()
var github = Helper.GetAuthenticatedClient();

var readmeHtml = await github.Repository.Content.GetReadmeHtml("octokit", "octokit.net");
Assert.True(readmeHtml.StartsWith("<div class="));
Assert.Contains(@"data-path=""README.md"" id=""readme""", readmeHtml);
Assert.True(readmeHtml.StartsWith("<div id="));
Assert.Contains("data-path=\"README.md\"", readmeHtml);
Assert.Contains("Octokit - GitHub API Client Library for .NET", readmeHtml);
}

Expand All @@ -53,8 +53,8 @@ public async Task ReturnsReadmeHtmlForSeeGitWithRepositoryId()
var github = Helper.GetAuthenticatedClient();

var readmeHtml = await github.Repository.Content.GetReadmeHtml(7528679);
Assert.True(readmeHtml.StartsWith("<div class="));
Assert.Contains(@"data-path=""README.md"" id=""readme""", readmeHtml);
Assert.True(readmeHtml.StartsWith("<div id="));
Assert.Contains("data-path=\"README.md\"", readmeHtml);
Assert.Contains("Octokit - GitHub API Client Library for .NET", readmeHtml);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -235,8 +235,8 @@ public async Task CreateAWebHookForTestRepository()
Assert.Equal(baseHookUrl + "/pings", hook.PingUrl);
Assert.NotNull(hook.CreatedAt);
Assert.NotNull(hook.UpdatedAt);
Assert.Equal(webHookConfig.Keys, hook.Config.Keys);
Assert.Equal(webHookConfig.Values, hook.Config.Values);
Assert.Equal(webHookConfig.Keys.OrderBy(x => x), hook.Config.Keys.OrderBy(x => x));
Assert.Equal(webHookConfig.Values.OrderBy(x => x), hook.Config.Values.OrderBy(x => x));
Assert.Equal(false, hook.Active);
}

Expand Down Expand Up @@ -279,8 +279,8 @@ public async Task CreateAWebHookForTestRepositoryWithRepositoryId()
Assert.Equal(baseHookUrl + "/pings", hook.PingUrl);
Assert.NotNull(hook.CreatedAt);
Assert.NotNull(hook.UpdatedAt);
Assert.Equal(webHookConfig.Keys, hook.Config.Keys);
Assert.Equal(webHookConfig.Values, hook.Config.Values);
Assert.Equal(webHookConfig.Keys.OrderBy(x => x), hook.Config.Keys.OrderBy(x => x));
Assert.Equal(webHookConfig.Values.OrderBy(x => x), hook.Config.Values.OrderBy(x => x));
Assert.Equal(false, hook.Active);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,9 @@ public async Task UpdatesCheckRun()
var checkRun = await _githubAppInstallation.Check.Run.Create(repoContext.RepositoryOwner, repoContext.RepositoryName, newCheckRun);

// Update the check run
var update = new CheckRunUpdate("new-name")
var update = new CheckRunUpdate
{
Name = "new-name",
Status = CheckStatus.InProgress
};
var result = await _githubAppInstallation.Check.Run.Update(repoContext.RepositoryOwner, repoContext.RepositoryName, checkRun.Id, update);
Expand Down Expand Up @@ -129,8 +130,9 @@ public async Task UpdatesCheckRunWithRepositoryId()
var checkRun = await _githubAppInstallation.Check.Run.Create(repoContext.RepositoryId, newCheckRun);

// Update the check run
var update = new CheckRunUpdate("new-name")
var update = new CheckRunUpdate
{
Name = "new-name",
Status = CheckStatus.InProgress
};
var result = await _githubAppInstallation.Check.Run.Update(repoContext.RepositoryId, checkRun.Id, update);
Expand Down
10 changes: 5 additions & 5 deletions Octokit.Tests/Clients/CheckRunsClientTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ public async Task RequestsCorrectUrl()
var connection = Substitute.For<IApiConnection>();
var client = new CheckRunsClient(connection);

var update = new CheckRunUpdate("status") { Status = CheckStatus.InProgress };
var update = new CheckRunUpdate { Status = CheckStatus.InProgress };

await client.Update("fake", "repo", 1, update);

Expand All @@ -103,7 +103,7 @@ public async Task RequestsCorrectUrlWithRepositoryId()
var connection = Substitute.For<IApiConnection>();
var client = new CheckRunsClient(connection);

var update = new CheckRunUpdate("status") { Status = CheckStatus.InProgress };
var update = new CheckRunUpdate { Status = CheckStatus.InProgress };

await client.Update(1, 1, update);

Expand All @@ -119,7 +119,7 @@ public async Task EnsuresNonNullArguments()
var connection = Substitute.For<IApiConnection>();
var client = new CheckRunsClient(connection);

var update = new CheckRunUpdate("status") { Status = CheckStatus.InProgress };
var update = new CheckRunUpdate { Status = CheckStatus.InProgress };

await Assert.ThrowsAsync<ArgumentNullException>(() => client.Update(null, "repo", 1, update));
await Assert.ThrowsAsync<ArgumentNullException>(() => client.Update("fake", null, 1, update));
Expand All @@ -132,7 +132,7 @@ public async Task EnsuresNonEmptyArguments()
var connection = Substitute.For<IApiConnection>();
var client = new CheckRunsClient(connection);

var update = new CheckRunUpdate("status") { Status = CheckStatus.InProgress };
var update = new CheckRunUpdate { Status = CheckStatus.InProgress };

await Assert.ThrowsAsync<ArgumentException>(() => client.Update("", "repo", 1, update));
await Assert.ThrowsAsync<ArgumentException>(() => client.Update("fake", "", 1, update));
Expand Down Expand Up @@ -610,7 +610,7 @@ public async Task EnsuresNonNullArguments()
await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetAllAnnotations(null, "repo", 1, ApiOptions.None));
await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetAllAnnotations("fake", null, 1, ApiOptions.None));
await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetAllAnnotations("fake", "repo", 1, null));

await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetAllAnnotations(1, 1, null));
}

Expand Down
6 changes: 3 additions & 3 deletions Octokit.Tests/Clients/ProjectCardsClientTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,9 @@ public async Task SendsAppropriateParameters()

connection.Received().GetAll<ProjectCard>(
Arg.Is<Uri>(u => u.ToString() == "projects/columns/1/cards"),
Arg.Is<Dictionary<string,string>>(x =>
x.Count == 1
&& x["archived_state"] == "not_archived"),
Arg.Is<Dictionary<string, string>>(x =>
x.Count == 1
&& x["archived_state"] == "not_archived"),
"application/vnd.github.inertia-preview+json",
Args.ApiOptions);
}
Expand Down
18 changes: 9 additions & 9 deletions Octokit.Tests/Clients/RepositoriesClientTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ await Assert.ThrowsAsync<ArgumentNullException>(
await Assert.ThrowsAsync<ArgumentNullException>(
() => client.Transfer("owner", "name", null));
}

[Fact]
public async Task EnsuresNonNullArgumentsById()
{
Expand Down Expand Up @@ -258,7 +258,7 @@ public async Task RequestsCorrectUrl()
{
var connection = Substitute.For<IApiConnection>();
var client = new RepositoriesClient(connection);
var teamId = new int[2] {35, 42};
var teamId = new int[2] { 35, 42 };
var transfer = new RepositoryTransfer("newOwner", teamId);

await client.Transfer("owner", "name", transfer);
Expand All @@ -269,13 +269,13 @@ public async Task RequestsCorrectUrl()
Arg.Any<RepositoryTransfer>(),
Arg.Any<string>());
}

[Fact]
public async Task RequestsCorrectUrlById()
{
var connection = Substitute.For<IApiConnection>();
var client = new RepositoriesClient(connection);
var teamId = new int[2] {35, 42};
var teamId = new int[2] { 35, 42 };
var transfer = new RepositoryTransfer("newOwner", teamId);
var repositoryId = 1;

Expand All @@ -293,7 +293,7 @@ public async Task SendsCorrectRequest()
{
var connection = Substitute.For<IApiConnection>();
var client = new RepositoriesClient(connection);
var teamId = new int[2] {35, 42};
var teamId = new int[2] { 35, 42 };
var transfer = new RepositoryTransfer("newOwner", teamId);

await client.Transfer("owner", "name", transfer);
Expand All @@ -305,13 +305,13 @@ public async Task SendsCorrectRequest()
t => t.NewOwner == "newOwner" && object.Equals(teamId, t.TeamIds)),
Arg.Any<string>());
}

[Fact]
public async Task SendsCorrectRequestById()
{
var connection = Substitute.For<IApiConnection>();
var client = new RepositoriesClient(connection);
var teamId = new int[2] {35, 42};
var teamId = new int[2] { 35, 42 };
var transfer = new RepositoryTransfer("newOwner", teamId);
var repositoryId = 1;

Expand All @@ -330,7 +330,7 @@ public async Task SendsPreviewHeader()
{
var connection = Substitute.For<IApiConnection>();
var client = new RepositoriesClient(connection);
var teamId = new int[2] {35, 42};
var teamId = new int[2] { 35, 42 };
var transfer = new RepositoryTransfer("newOwner", teamId);

await client.Transfer("owner", "name", transfer);
Expand All @@ -348,7 +348,7 @@ public async Task SendsPreviewHeaderById()
{
var connection = Substitute.For<IApiConnection>();
var client = new RepositoriesClient(connection);
var teamId = new int[2] {35, 42};
var teamId = new int[2] { 35, 42 };
var transfer = new RepositoryTransfer("newOwner", teamId);
var repositoryId = 1;

Expand Down
16 changes: 8 additions & 8 deletions Octokit.Tests/Models/RepositoryTransferTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,21 @@ public class RepositoryTransferTest
{
public static readonly string emptyName = "";
public static readonly string nonemptyName = "name";
public static readonly int[] emptyTeamId = new int[] {};
public static readonly int[] nonemptyTeamId = new int[] {1, 2, 3};
public static readonly int[] emptyTeamId = new int[] { };
public static readonly int[] nonemptyTeamId = new int[] { 1, 2, 3 };

public class TheSingleArgumentConstructor
{
[Fact]
public void ChecksForEmptyName()
{
Assert.Throws<ArgumentException>(() => {new RepositoryTransfer(emptyName);});
Assert.Throws<ArgumentException>(() => { new RepositoryTransfer(emptyName); });
}

[Fact]
public void ChecksForNullName()
{
Assert.Throws<ArgumentNullException>(() => {new RepositoryTransfer(null);});
Assert.Throws<ArgumentNullException>(() => { new RepositoryTransfer(null); });
}

[Fact]
Expand All @@ -45,25 +45,25 @@ public class TheFullConstructor
[Fact]
public void ChecksForEmptyName()
{
Assert.Throws<ArgumentException>(() => {new RepositoryTransfer(emptyName, nonemptyTeamId);});
Assert.Throws<ArgumentException>(() => { new RepositoryTransfer(emptyName, nonemptyTeamId); });
}

[Fact]
public void ChecksForNullName()
{
Assert.Throws<ArgumentNullException>(() => {new RepositoryTransfer(null, nonemptyTeamId);});
Assert.Throws<ArgumentNullException>(() => { new RepositoryTransfer(null, nonemptyTeamId); });
}

[Fact]
public void ChecksForEmptyTeamId()
{
Assert.Throws<ArgumentException>(() => {new RepositoryTransfer(nonemptyName, emptyTeamId);});
Assert.Throws<ArgumentException>(() => { new RepositoryTransfer(nonemptyName, emptyTeamId); });
}

[Fact]
public void ChecksForNullTeamId()
{
Assert.Throws<ArgumentNullException>(() => {new RepositoryTransfer(nonemptyName, null);});
Assert.Throws<ArgumentNullException>(() => { new RepositoryTransfer(nonemptyName, null); });
}

[Fact]
Expand Down
Loading

0 comments on commit 1015220

Please sign in to comment.