Skip to content

Commit

Permalink
Update pull requests client and tests to use draft PR accept header
Browse files Browse the repository at this point in the history
  • Loading branch information
hnrkndrssn committed Sep 21, 2019
1 parent ccb14b5 commit 9a0b8e6
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 22 deletions.
28 changes: 14 additions & 14 deletions Octokit.Tests/Clients/PullRequestsClientTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public async Task RequestsCorrectUrl()

await client.Get("fake", "repo", 42);

connection.Received().Get<PullRequest>(Arg.Is<Uri>(u => u.ToString() == "repos/fake/repo/pulls/42"));
connection.Received().Get<PullRequest>(Arg.Is<Uri>(u => u.ToString() == "repos/fake/repo/pulls/42"), Arg.Any<Dictionary<string, string>>(), "application/vnd.github.shadow-cat-preview+json");
}

[Fact]
Expand All @@ -29,7 +29,7 @@ public async Task RequestsCorrectUrlWithRepositoryId()

await client.Get(1, 42);

connection.Received().Get<PullRequest>(Arg.Is<Uri>(u => u.ToString() == "repositories/1/pulls/42"));
connection.Received().Get<PullRequest>(Arg.Is<Uri>(u => u.ToString() == "repositories/1/pulls/42"), Arg.Any<Dictionary<string, string>>(), "application/vnd.github.shadow-cat-preview+json");
}

[Fact]
Expand All @@ -56,7 +56,7 @@ public async Task RequestsCorrectUrl()
await client.GetAllForRepository("fake", "repo");

connection.Received().GetAll<PullRequest>(Arg.Is<Uri>(u => u.ToString() == "repos/fake/repo/pulls"),
Arg.Any<Dictionary<string, string>>(), Args.ApiOptions);
Arg.Any<Dictionary<string, string>>(), "application/vnd.github.shadow-cat-preview+json", Args.ApiOptions);
}

[Fact]
Expand All @@ -68,7 +68,7 @@ public async Task RequestsCorrectUrlWithRepositoryId()
await client.GetAllForRepository(1);

connection.Received().GetAll<PullRequest>(Arg.Is<Uri>(u => u.ToString() == "repositories/1/pulls"),
Arg.Any<Dictionary<string, string>>(), Args.ApiOptions);
Arg.Any<Dictionary<string, string>>(), "application/vnd.github.shadow-cat-preview+json", Args.ApiOptions);
}

[Fact]
Expand All @@ -87,7 +87,7 @@ public async Task RequestsCorrectUrlWithApiOptions()
await client.GetAllForRepository("fake", "repo", options);

connection.Received().GetAll<PullRequest>(Arg.Is<Uri>(u => u.ToString() == "repos/fake/repo/pulls"),
Arg.Any<Dictionary<string, string>>(), options);
Arg.Any<Dictionary<string, string>>(), "application/vnd.github.shadow-cat-preview+json", options);
}

[Fact]
Expand All @@ -106,7 +106,7 @@ public async Task RequestsCorrectUrlWithApiOptionsWithRepositoryId()
await client.GetAllForRepository(1, options);

connection.Received().GetAll<PullRequest>(Arg.Is<Uri>(u => u.ToString() == "repositories/1/pulls"),
Arg.Any<Dictionary<string, string>>(), options);
Arg.Any<Dictionary<string, string>>(), "application/vnd.github.shadow-cat-preview+json", options);
}

[Fact]
Expand All @@ -123,7 +123,7 @@ public async Task SendsAppropriateParameters()
&& d["state"] == "open"
&& d["base"] == "fake_base_branch"
&& d["sort"] == "created"
&& d["direction"] == "desc"), Args.ApiOptions);
&& d["direction"] == "desc"), "application/vnd.github.shadow-cat-preview+json", Args.ApiOptions);
}

[Fact]
Expand All @@ -140,7 +140,7 @@ public async Task SendsAppropriateParametersWithRepositoryId()
&& d["state"] == "open"
&& d["base"] == "fake_base_branch"
&& d["sort"] == "created"
&& d["direction"] == "desc"), Args.ApiOptions);
&& d["direction"] == "desc"), "application/vnd.github.shadow-cat-preview+json", Args.ApiOptions);
}

[Fact]
Expand All @@ -164,7 +164,7 @@ public async Task SendsAppropriateParametersWithApiOptions()
&& d["state"] == "open"
&& d["base"] == "fake_base_branch"
&& d["sort"] == "created"
&& d["direction"] == "desc"), options);
&& d["direction"] == "desc"), "application/vnd.github.shadow-cat-preview+json", options);
}

[Fact]
Expand All @@ -188,7 +188,7 @@ public async Task SendsAppropriateParametersWithApiOptionsWithRepositoryId()
&& d["state"] == "open"
&& d["base"] == "fake_base_branch"
&& d["sort"] == "created"
&& d["direction"] == "desc"), options);
&& d["direction"] == "desc"), "application/vnd.github.shadow-cat-preview+json", options);
}

[Fact]
Expand Down Expand Up @@ -243,7 +243,7 @@ public async Task PostsToCorrectUrl()
await client.Create("fake", "repo", newPullRequest);

connection.Received().Post<PullRequest>(Arg.Is<Uri>(u => u.ToString() == "repos/fake/repo/pulls"),
newPullRequest);
newPullRequest, "application/vnd.github.shadow-cat-preview+json");
}

[Fact]
Expand All @@ -256,7 +256,7 @@ public async Task PostsToCorrectUrlWithRepositoryId()
await client.Create(1, newPullRequest);

connection.Received().Post<PullRequest>(Arg.Is<Uri>(u => u.ToString() == "repositories/1/pulls"),
newPullRequest);
newPullRequest, "application/vnd.github.shadow-cat-preview+json");
}

[Fact]
Expand Down Expand Up @@ -288,7 +288,7 @@ public async Task PostsToCorrectUrl()
await client.Update("fake", "repo", 42, pullRequestUpdate);

connection.Received().Patch<PullRequest>(Arg.Is<Uri>(u => u.ToString() == "repos/fake/repo/pulls/42"),
pullRequestUpdate);
pullRequestUpdate, "application/vnd.github.shadow-cat-preview+json");
}

[Fact]
Expand All @@ -301,7 +301,7 @@ public async Task PostsToCorrectUrlWithRepositoryId()
await client.Update(1, 42, pullRequestUpdate);

connection.Received().Patch<PullRequest>(Arg.Is<Uri>(u => u.ToString() == "repositories/1/pulls/42"),
pullRequestUpdate);
pullRequestUpdate, "application/vnd.github.shadow-cat-preview+json");
}

[Fact]
Expand Down
16 changes: 8 additions & 8 deletions Octokit/Clients/PullRequestsClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public Task<PullRequest> Get(string owner, string name, int number)
Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner));
Ensure.ArgumentNotNullOrEmptyString(name, nameof(name));

return ApiConnection.Get<PullRequest>(ApiUrls.PullRequest(owner, name, number));
return ApiConnection.Get<PullRequest>(ApiUrls.PullRequest(owner, name, number), null,AcceptHeaders.DraftPullRequestApiPreview);
}

/// <summary>
Expand All @@ -57,7 +57,7 @@ public Task<PullRequest> Get(string owner, string name, int number)
/// </remarks>
public Task<PullRequest> Get(long repositoryId, int number)
{
return ApiConnection.Get<PullRequest>(ApiUrls.PullRequest(repositoryId, number));
return ApiConnection.Get<PullRequest>(ApiUrls.PullRequest(repositoryId, number), null, AcceptHeaders.DraftPullRequestApiPreview);
}

/// <summary>
Expand Down Expand Up @@ -172,7 +172,7 @@ public Task<IReadOnlyList<PullRequest>> GetAllForRepository(string owner, string
Ensure.ArgumentNotNull(options, nameof(options));

return ApiConnection.GetAll<PullRequest>(ApiUrls.PullRequests(owner, name),
request.ToParametersDictionary(), options);
request.ToParametersDictionary(), AcceptHeaders.DraftPullRequestApiPreview, options);
}

/// <summary>
Expand All @@ -190,7 +190,7 @@ public Task<IReadOnlyList<PullRequest>> GetAllForRepository(long repositoryId, P
Ensure.ArgumentNotNull(options, nameof(options));

return ApiConnection.GetAll<PullRequest>(ApiUrls.PullRequests(repositoryId),
request.ToParametersDictionary(), options);
request.ToParametersDictionary(), AcceptHeaders.DraftPullRequestApiPreview, options);
}

/// <summary>
Expand All @@ -206,7 +206,7 @@ public Task<PullRequest> Create(string owner, string name, NewPullRequest newPul
Ensure.ArgumentNotNullOrEmptyString(name, nameof(name));
Ensure.ArgumentNotNull(newPullRequest, nameof(newPullRequest));

return ApiConnection.Post<PullRequest>(ApiUrls.PullRequests(owner, name), newPullRequest);
return ApiConnection.Post<PullRequest>(ApiUrls.PullRequests(owner, name), newPullRequest, AcceptHeaders.DraftPullRequestApiPreview);
}

/// <summary>
Expand All @@ -219,7 +219,7 @@ public Task<PullRequest> Create(long repositoryId, NewPullRequest newPullRequest
{
Ensure.ArgumentNotNull(newPullRequest, nameof(newPullRequest));

return ApiConnection.Post<PullRequest>(ApiUrls.PullRequests(repositoryId), newPullRequest);
return ApiConnection.Post<PullRequest>(ApiUrls.PullRequests(repositoryId), newPullRequest, AcceptHeaders.DraftPullRequestApiPreview);
}

/// <summary>
Expand All @@ -237,7 +237,7 @@ public Task<PullRequest> Update(string owner, string name, int number, PullReque
Ensure.ArgumentNotNullOrEmptyString(name, nameof(name));
Ensure.ArgumentNotNull(pullRequestUpdate, nameof(pullRequestUpdate));

return ApiConnection.Patch<PullRequest>(ApiUrls.PullRequest(owner, name, number), pullRequestUpdate);
return ApiConnection.Patch<PullRequest>(ApiUrls.PullRequest(owner, name, number), pullRequestUpdate, AcceptHeaders.DraftPullRequestApiPreview);
}

/// <summary>
Expand All @@ -252,7 +252,7 @@ public Task<PullRequest> Update(long repositoryId, int number, PullRequestUpdate
{
Ensure.ArgumentNotNull(pullRequestUpdate, nameof(pullRequestUpdate));

return ApiConnection.Patch<PullRequest>(ApiUrls.PullRequest(repositoryId, number), pullRequestUpdate);
return ApiConnection.Patch<PullRequest>(ApiUrls.PullRequest(repositoryId, number), pullRequestUpdate, AcceptHeaders.DraftPullRequestApiPreview);
}

/// <summary>
Expand Down

0 comments on commit 9a0b8e6

Please sign in to comment.