Implement Draft Pull Requests (#2009)

* Add draft PR preview header

* Add Draft property to models

* Update pull requests client and tests to use draft PR accept header

* Update observable pull requests client and tests to use draft PR accept header

* Add integration tests to create and retrieve draft pull requests
This commit is contained in:
Henrik Andersson
2019-09-23 02:38:56 +10:00
committed by Brendan Forster
parent d955d7facd
commit fafbf33b78
8 changed files with 106 additions and 39 deletions
@@ -209,11 +209,11 @@ namespace Octokit.Tests.Reactive
}
);
var gitHubClient = Substitute.For<IGitHubClient>();
gitHubClient.Connection.Get<List<PullRequest>>(firstPageUrl, Args.EmptyDictionary, null)
gitHubClient.Connection.Get<List<PullRequest>>(firstPageUrl, Args.EmptyDictionary, "application/vnd.github.shadow-cat-preview+json")
.Returns(Task.Factory.StartNew<IApiResponse<List<PullRequest>>>(() => firstPageResponse));
gitHubClient.Connection.Get<List<PullRequest>>(secondPageUrl, Args.EmptyDictionary, null)
gitHubClient.Connection.Get<List<PullRequest>>(secondPageUrl, Args.EmptyDictionary, "application/vnd.github.shadow-cat-preview+json")
.Returns(Task.Factory.StartNew<IApiResponse<List<PullRequest>>>(() => secondPageResponse));
gitHubClient.Connection.Get<List<PullRequest>>(thirdPageUrl, Args.EmptyDictionary, null)
gitHubClient.Connection.Get<List<PullRequest>>(thirdPageUrl, Args.EmptyDictionary, "application/vnd.github.shadow-cat-preview+json")
.Returns(Task.Factory.StartNew<IApiResponse<List<PullRequest>>>(() => lastPageResponse));
var client = new ObservablePullRequestsClient(gitHubClient);
@@ -262,11 +262,11 @@ namespace Octokit.Tests.Reactive
}
);
var gitHubClient = Substitute.For<IGitHubClient>();
gitHubClient.Connection.Get<List<PullRequest>>(firstPageUrl, Args.EmptyDictionary, null)
gitHubClient.Connection.Get<List<PullRequest>>(firstPageUrl, Args.EmptyDictionary, "application/vnd.github.shadow-cat-preview+json")
.Returns(Task.Factory.StartNew<IApiResponse<List<PullRequest>>>(() => firstPageResponse));
gitHubClient.Connection.Get<List<PullRequest>>(secondPageUrl, Args.EmptyDictionary, null)
gitHubClient.Connection.Get<List<PullRequest>>(secondPageUrl, Args.EmptyDictionary, "application/vnd.github.shadow-cat-preview+json")
.Returns(Task.Factory.StartNew<IApiResponse<List<PullRequest>>>(() => secondPageResponse));
gitHubClient.Connection.Get<List<PullRequest>>(thirdPageUrl, Args.EmptyDictionary, null)
gitHubClient.Connection.Get<List<PullRequest>>(thirdPageUrl, Args.EmptyDictionary, "application/vnd.github.shadow-cat-preview+json")
.Returns(Task.Factory.StartNew<IApiResponse<List<PullRequest>>>(() => lastPageResponse));
var client = new ObservablePullRequestsClient(gitHubClient);
@@ -321,21 +321,21 @@ namespace Octokit.Tests.Reactive
&& d["state"] == "open"
&& d["base"] == "fake_base_branch"
&& d["sort"] == "created"
&& d["direction"] == "desc"), Arg.Any<string>())
&& d["direction"] == "desc"), "application/vnd.github.shadow-cat-preview+json")
.Returns(Task.Factory.StartNew<IApiResponse<List<PullRequest>>>(() => firstPageResponse));
gitHubClient.Connection.Get<List<PullRequest>>(secondPageUrl, Arg.Is<Dictionary<string, string>>(d => d.Count == 5
&& d["head"] == "user:ref-name"
&& d["state"] == "open"
&& d["base"] == "fake_base_branch"
&& d["sort"] == "created"
&& d["direction"] == "desc"), null)
&& d["direction"] == "desc"), "application/vnd.github.shadow-cat-preview+json")
.Returns(Task.Factory.StartNew<IApiResponse<List<PullRequest>>>(() => secondPageResponse));
gitHubClient.Connection.Get<List<PullRequest>>(thirdPageUrl, Arg.Is<Dictionary<string, string>>(d => d.Count == 5
&& d["head"] == "user:ref-name"
&& d["state"] == "open"
&& d["base"] == "fake_base_branch"
&& d["sort"] == "created"
&& d["direction"] == "desc"), null)
&& d["direction"] == "desc"), "application/vnd.github.shadow-cat-preview+json")
.Returns(Task.Factory.StartNew<IApiResponse<List<PullRequest>>>(() => lastPageResponse));
var client = new ObservablePullRequestsClient(gitHubClient);
@@ -390,21 +390,21 @@ namespace Octokit.Tests.Reactive
&& d["state"] == "open"
&& d["base"] == "fake_base_branch"
&& d["sort"] == "created"
&& d["direction"] == "desc"), Arg.Any<string>())
&& d["direction"] == "desc"), "application/vnd.github.shadow-cat-preview+json")
.Returns(Task.Factory.StartNew<IApiResponse<List<PullRequest>>>(() => firstPageResponse));
gitHubClient.Connection.Get<List<PullRequest>>(secondPageUrl, Arg.Is<Dictionary<string, string>>(d => d.Count == 5
&& d["head"] == "user:ref-name"
&& d["state"] == "open"
&& d["base"] == "fake_base_branch"
&& d["sort"] == "created"
&& d["direction"] == "desc"), null)
&& d["direction"] == "desc"), "application/vnd.github.shadow-cat-preview+json")
.Returns(Task.Factory.StartNew<IApiResponse<List<PullRequest>>>(() => secondPageResponse));
gitHubClient.Connection.Get<List<PullRequest>>(thirdPageUrl, Arg.Is<Dictionary<string, string>>(d => d.Count == 5
&& d["head"] == "user:ref-name"
&& d["state"] == "open"
&& d["base"] == "fake_base_branch"
&& d["sort"] == "created"
&& d["direction"] == "desc"), null)
&& d["direction"] == "desc"), "application/vnd.github.shadow-cat-preview+json")
.Returns(Task.Factory.StartNew<IApiResponse<List<PullRequest>>>(() => lastPageResponse));
var client = new ObservablePullRequestsClient(gitHubClient);