Skip to content

Commit

Permalink
remove deprecated code for old Check Suites API (#2130)
Browse files Browse the repository at this point in the history
  • Loading branch information
shiftkey authored Mar 5, 2020
1 parent f968856 commit 43d1b8b
Show file tree
Hide file tree
Showing 7 changed files with 4 additions and 279 deletions.
25 changes: 1 addition & 24 deletions Octokit.Reactive/Clients/IObservableCheckSuitesClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -142,29 +142,6 @@ public interface IObservableCheckSuitesClient
/// <param name="newCheckSuite">Details of the Check Suite to create</param>
IObservable<CheckSuite> Create(long repositoryId, NewCheckSuite newCheckSuite);

/// <summary>
/// Triggers GitHub to create a new check suite, without pushing new code to a repository
/// </summary>
/// <remarks>
/// See the <a href="https://developer.github.com/v3/checks/suites/#request-check-suites">Check Suites API documentation</a> for more information.
/// </remarks>
/// <param name="owner">The owner of the repository</param>
/// <param name="name">The name of the repository</param>
/// <param name="request">Details of the Check Suite request</param>
[Obsolete("This method has been deprecated in the GitHub Api, however can still be used on GitHub Enterprise 2.14")]
IObservable<bool> Request(string owner, string name, CheckSuiteTriggerRequest request);

/// <summary>
/// Triggers GitHub to create a new check suite, without pushing new code to a repository
/// </summary>
/// <remarks>
/// See the <a href="https://developer.github.com/v3/checks/suites/#request-check-suites">Check Suites API documentation</a> for more information.
/// </remarks>
/// <param name="repositoryId">The Id of the repository</param>
/// <param name="request">Details of the Check Suite request</param>
[Obsolete("This method has been deprecated in the GitHub Api, however can still be used on GitHub Enterprise 2.14")]
IObservable<bool> Request(long repositoryId, CheckSuiteTriggerRequest request);

/// <summary>
/// Triggers GitHub to rerequest an existing check suite, without pushing new code to a repository
/// </summary>
Expand All @@ -186,4 +163,4 @@ public interface IObservableCheckSuitesClient
/// <param name="checkSuiteId">The Id of the check suite</param>
IObservable<bool> Rerequest(long repositoryId, long checkSuiteId);
}
}
}
37 changes: 1 addition & 36 deletions Octokit.Reactive/Clients/ObservableCheckSuitesClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -234,41 +234,6 @@ public IObservable<CheckSuite> Create(long repositoryId, NewCheckSuite newCheckS
return _client.Create(repositoryId, newCheckSuite).ToObservable();
}

/// <summary>
/// Triggers GitHub to create a new check suite, without pushing new code to a repository
/// </summary>
/// <remarks>
/// See the <a href="https://developer.github.com/v3/checks/suites/#request-check-suites">Check Suites API documentation</a> for more information.
/// </remarks>
/// <param name="owner">The owner of the repository</param>
/// <param name="name">The name of the repository</param>
/// <param name="request">Details of the Check Suite request</param>
[Obsolete("This method has been deprecated in the GitHub Api, however can still be used on GitHub Enterprise 2.14")]
public IObservable<bool> Request(string owner, string name, CheckSuiteTriggerRequest request)
{
Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner));
Ensure.ArgumentNotNullOrEmptyString(name, nameof(name));
Ensure.ArgumentNotNull(request, nameof(request));

return _client.Request(owner, name, request).ToObservable();
}

/// <summary>
/// Triggers GitHub to create a new check suite, without pushing new code to a repository
/// </summary>
/// <remarks>
/// See the <a href="https://developer.github.com/v3/checks/suites/#request-check-suites">Check Suites API documentation</a> for more information.
/// </remarks>
/// <param name="repositoryId">The Id of the repository</param>
/// <param name="request">Details of the Check Suite request</param>
[Obsolete("This method has been deprecated in the GitHub Api, however can still be used on GitHub Enterprise 2.14")]
public IObservable<bool> Request(long repositoryId, CheckSuiteTriggerRequest request)
{
Ensure.ArgumentNotNull(request, nameof(request));

return _client.Request(repositoryId, request).ToObservable();
}

/// <summary>
/// Triggers GitHub to rerequest an existing check suite, without pushing new code to a repository
/// </summary>
Expand Down Expand Up @@ -299,4 +264,4 @@ public IObservable<bool> Rerequest(long repositoryId, long checkSuiteId)
return _client.Rerequest(repositoryId, checkSuiteId).ToObservable();
}
}
}
}
66 changes: 1 addition & 65 deletions Octokit.Tests/Clients/CheckSuitesClientTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -332,70 +332,6 @@ public async Task EnsuresNonEmptyArguments()
}
}

#pragma warning disable CS0618 // Type or member is obsolete
public class TheRequestMethod
{
[Fact]
public async Task RequestsCorrectUrl()
{
var connection = MockedIApiConnection.PostReturnsHttpStatus(HttpStatusCode.Created);
var client = new CheckSuitesClient(connection);

var request = new CheckSuiteTriggerRequest("123abc");

await client.Request("fake", "repo", request);

connection.Connection.Received().Post(
Arg.Is<Uri>(u => u.ToString() == "repos/fake/repo/check-suite-requests"),
request,
"application/vnd.github.antiope-preview+json");
}

[Fact]
public async Task RequestsCorrectUrlWithRepositoryId()
{
var connection = MockedIApiConnection.PostReturnsHttpStatus(HttpStatusCode.Created);
var client = new CheckSuitesClient(connection);

var request = new CheckSuiteTriggerRequest("123abc");

await client.Request(1, request);

connection.Connection.Received().Post(
Arg.Is<Uri>(u => u.ToString() == "repositories/1/check-suite-requests"),
request,
"application/vnd.github.antiope-preview+json");
}

[Fact]
public async Task EnsuresNonNullArguments()
{
var connection = Substitute.For<IApiConnection>();
var client = new CheckSuitesClient(connection);

var request = new CheckSuiteTriggerRequest("123abc");

await Assert.ThrowsAsync<ArgumentNullException>(() => client.Request(null, "repo", request));
await Assert.ThrowsAsync<ArgumentNullException>(() => client.Request("fake", null, request));
await Assert.ThrowsAsync<ArgumentNullException>(() => client.Request("fake", "repo", null));

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

[Fact]
public async Task EnsuresNonEmptyArguments()
{
var connection = Substitute.For<IApiConnection>();
var client = new CheckSuitesClient(connection);

var request = new CheckSuiteTriggerRequest("123abc");

await Assert.ThrowsAsync<ArgumentException>(() => client.Request("", "repo", request));
await Assert.ThrowsAsync<ArgumentException>(() => client.Request("fake", "", request));
}
}
#pragma warning restore CS0618 // Type or member is obsolete

public class TheRerequestMethod
{
[Fact]
Expand Down Expand Up @@ -447,4 +383,4 @@ public async Task EnsuresNonEmptyArguments()
}
}
}
}
}
58 changes: 0 additions & 58 deletions Octokit.Tests/Reactive/ObservableCheckSuitesClientTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -313,64 +313,6 @@ public async Task EnsuresNonEmptyArguments()
}
}

#pragma warning disable CS0618 // Type or member is obsolete
public class TheRequestMethod
{
[Fact]
public async Task RequestsCorrectUrl()
{
var gitHubClient = Substitute.For<IGitHubClient>();
var client = new ObservableCheckSuitesClient(gitHubClient);

var request = new CheckSuiteTriggerRequest("123abc");

client.Request("fake", "repo", request);

gitHubClient.Check.Suite.Received().Request("fake", "repo", request);
}

[Fact]
public async Task RequestsCorrectUrlWithRepositoryId()
{
var gitHubClient = Substitute.For<IGitHubClient>();
var client = new ObservableCheckSuitesClient(gitHubClient);

var request = new CheckSuiteTriggerRequest("123abc");

client.Request(1, request);

gitHubClient.Check.Suite.Received().Request(1, request);
}

[Fact]
public async Task EnsuresNonNullArguments()
{
var gitHubClient = Substitute.For<IGitHubClient>();
var client = new ObservableCheckSuitesClient(gitHubClient);

var request = new CheckSuiteTriggerRequest("123abc");

Assert.Throws<ArgumentNullException>(() => client.Request(null, "repo", request));
Assert.Throws<ArgumentNullException>(() => client.Request("fake", null, request));
Assert.Throws<ArgumentNullException>(() => client.Request("fake", "repo", null));

Assert.Throws<ArgumentNullException>(() => client.Request(1, null));
}

[Fact]
public async Task EnsuresNonEmptyArguments()
{
var gitHubClient = Substitute.For<IGitHubClient>();
var client = new ObservableCheckSuitesClient(gitHubClient);

var request = new CheckSuiteTriggerRequest("123abc");

Assert.Throws<ArgumentException>(() => client.Request("", "repo", request));
Assert.Throws<ArgumentException>(() => client.Request("fake", "", request));
}
}
#pragma warning restore CS0618 // Type or member is obsolete

public class TheRerequestMethod
{
[Fact]
Expand Down
49 changes: 0 additions & 49 deletions Octokit/Clients/CheckSuitesClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -248,55 +248,6 @@ public Task<CheckSuite> Create(long repositoryId, NewCheckSuite newCheckSuite)
return ApiConnection.Post<CheckSuite>(ApiUrls.CheckSuites(repositoryId), newCheckSuite, AcceptHeaders.ChecksApiPreview);
}

/// <summary>
/// Triggers GitHub to create a new check suite, without pushing new code to a repository
/// </summary>
/// <remarks>
/// See the <a href="https://developer.github.com/v3/checks/suites/#request-check-suites">Check Suites API documentation</a> for more information.
/// </remarks>
/// <param name="owner">The owner of the repository</param>
/// <param name="name">The name of the repository</param>
/// <param name="request">Details of the Check Suite request</param>
[Obsolete("This method has been deprecated in the GitHub Api, however can still be used on GitHub Enterprise 2.14")]
public async Task<bool> Request(string owner, string name, CheckSuiteTriggerRequest request)
{
Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner));
Ensure.ArgumentNotNullOrEmptyString(name, nameof(name));
Ensure.ArgumentNotNull(request, nameof(request));

var httpStatusCode = await Connection.Post(ApiUrls.CheckSuiteRequests(owner, name), request, AcceptHeaders.ChecksApiPreview).ConfigureAwait(false);

if (httpStatusCode != HttpStatusCode.Created)
{
throw new ApiException("Invalid Status Code returned. Expected a 201", httpStatusCode);
}

return httpStatusCode == HttpStatusCode.Created;
}

/// <summary>
/// Triggers GitHub to create a new check suite, without pushing new code to a repository
/// </summary>
/// <remarks>
/// See the <a href="https://developer.github.com/v3/checks/suites/#request-check-suites">Check Suites API documentation</a> for more information.
/// </remarks>
/// <param name="repositoryId">The Id of the repository</param>
/// <param name="request">Details of the Check Suite request</param>
[Obsolete("This method has been deprecated in the GitHub Api, however can still be used on GitHub Enterprise 2.14")]
public async Task<bool> Request(long repositoryId, CheckSuiteTriggerRequest request)
{
Ensure.ArgumentNotNull(request, nameof(request));

var httpStatusCode = await Connection.Post(ApiUrls.CheckSuiteRequests(repositoryId), request, AcceptHeaders.ChecksApiPreview).ConfigureAwait(false);

if (httpStatusCode != HttpStatusCode.Created)
{
throw new ApiException("Invalid Status Code returned. Expected a 201", httpStatusCode);
}

return httpStatusCode == HttpStatusCode.Created;
}

/// <summary>
/// Triggers GitHub to rerequest an existing check suite, without pushing new code to a repository
/// </summary>
Expand Down
25 changes: 1 addition & 24 deletions Octokit/Clients/ICheckSuitesClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -143,29 +143,6 @@ public interface ICheckSuitesClient
/// <param name="newCheckSuite">Details of the Check Suite to create</param>
Task<CheckSuite> Create(long repositoryId, NewCheckSuite newCheckSuite);

/// <summary>
/// Triggers GitHub to create a new check suite, without pushing new code to a repository
/// </summary>
/// <remarks>
/// See the <a href="https://developer.github.com/v3/checks/suites/#request-check-suites">Check Suites API documentation</a> for more information.
/// </remarks>
/// <param name="owner">The owner of the repository</param>
/// <param name="name">The name of the repository</param>
/// <param name="request">Details of the Check Suite request</param>
[Obsolete("This method has been deprecated in the GitHub Api, however can still be used on GitHub Enterprise 2.14")]
Task<bool> Request(string owner, string name, CheckSuiteTriggerRequest request);

/// <summary>
/// Triggers GitHub to create a new check suite, without pushing new code to a repository
/// </summary>
/// <remarks>
/// See the <a href="https://developer.github.com/v3/checks/suites/#request-check-suites">Check Suites API documentation</a> for more information.
/// </remarks>
/// <param name="repositoryId">The Id of the repository</param>
/// <param name="request">Details of the Check Suite request</param>
[Obsolete("This method has been deprecated in the GitHub Api, however can still be used on GitHub Enterprise 2.14")]
Task<bool> Request(long repositoryId, CheckSuiteTriggerRequest request);

/// <summary>
/// Triggers GitHub to rerequest an existing check suite, without pushing new code to a repository
/// </summary>
Expand All @@ -187,4 +164,4 @@ public interface ICheckSuitesClient
/// <param name="checkSuiteId">The Id of the check suite</param>
Task<bool> Rerequest(long repositoryId, long checkSuiteId);
}
}
}
23 changes: 0 additions & 23 deletions Octokit/Helpers/ApiUrls.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4090,29 +4090,6 @@ public static Uri CheckSuites(string owner, string repo)
return "repos/{0}/{1}/check-suites".FormatUri(owner, repo);
}

/// <summary>
/// Returns the <see cref="Uri"/> that handles the check suite requests for the repository.
/// </summary>
/// <param name="repositoryId">The Id of the repository</param>
/// <returns>The <see cref="Uri"/> that handles the check suite requests for the repository.</returns>
[Obsolete("This method has been deprecated in the GitHub Api, however can still be used on GitHub Enterprise 2.14")]
public static Uri CheckSuiteRequests(long repositoryId)
{
return "repositories/{0}/check-suite-requests".FormatUri(repositoryId);
}

/// <summary>
/// Returns the <see cref="Uri"/> that handles the check suite requests for the repository.
/// </summary>
/// <param name="owner">The owner of repo</param>
/// <param name="repo">The name of repo</param>
/// <returns>The <see cref="Uri"/> that handles the check suite requests for the repository.</returns>
[Obsolete("This method has been deprecated in the GitHub Api, however can still be used on GitHub Enterprise 2.14")]
public static Uri CheckSuiteRequests(string owner, string repo)
{
return "repos/{0}/{1}/check-suite-requests".FormatUri(owner, repo);
}

/// <summary>
/// Returns the <see cref="Uri"/> that handles the check suite requests for the repository.
/// </summary>
Expand Down

0 comments on commit 43d1b8b

Please sign in to comment.