From 1185da2bdd670246e54759638d406fed9317d12a Mon Sep 17 00:00:00 2001 From: Ryan Gribble Date: Thu, 7 Jul 2016 22:00:32 +1000 Subject: [PATCH] Fixup unit tests wth preview accepts header Also applied preview header to a couple of repositoryId based calls that were added by another PR --- .../Clients/IssueCommentsClientTests.cs | 36 +++++++++++++------ Octokit.Tests/Clients/IssuesClientTests.cs | 14 ++++++-- .../Reactive/ObservableIssuesClientTests.cs | 11 +++--- Octokit/Clients/IssueCommentsClient.cs | 6 ++-- Octokit/Clients/IssuesClient.cs | 4 +-- 5 files changed, 49 insertions(+), 22 deletions(-) diff --git a/Octokit.Tests/Clients/IssueCommentsClientTests.cs b/Octokit.Tests/Clients/IssueCommentsClientTests.cs index 2354e780f4..46a803a5fe 100644 --- a/Octokit.Tests/Clients/IssueCommentsClientTests.cs +++ b/Octokit.Tests/Clients/IssueCommentsClientTests.cs @@ -22,8 +22,8 @@ public async Task RequestsCorrectUrl() connection.Received().Get( Arg.Is(u => u.ToString() == "repos/fake/repo/issues/comments/42"), - Arg.Any>(), - Arg.Is(s => s == "application/vnd.github.squirrel-girl-preview")); + Arg.Any>(), + "application/vnd.github.squirrel-girl-preview"); } [Fact] @@ -34,7 +34,9 @@ public async Task RequestsCorrectUrlWithRepositoryId() await client.Get(1, 42); - connection.Received().Get(Arg.Is(u => u.ToString() == "repositories/1/issues/comments/42")); + connection.Received().Get(Arg.Is(u => u.ToString() == "repositories/1/issues/comments/42"), + Arg.Any>(), + "application/vnd.github.squirrel-girl-preview"); } [Fact] @@ -63,7 +65,7 @@ public async Task RequestsCorrectUrl() connection.Received().GetAll( Arg.Is(u => u.ToString() == "repos/fake/repo/issues/comments"), Arg.Any>(), - Arg.Is(s => s == "application/vnd.github.squirrel-girl-preview"), + "application/vnd.github.squirrel-girl-preview", Args.ApiOptions); } @@ -75,7 +77,10 @@ public async Task RequestsCorrectUrlWithRepositoryId() await client.GetAllForRepository(1); - connection.Received().GetAll(Arg.Is(u => u.ToString() == "repositories/1/issues/comments"), Args.ApiOptions); + connection.Received().GetAll(Arg.Is(u => u.ToString() == "repositories/1/issues/comments"), + Arg.Any>(), + "application/vnd.github.squirrel-girl-preview", + Args.ApiOptions); } [Fact] @@ -96,7 +101,7 @@ public async Task RequestsCorrectUrlWithApiOptions() connection.Received().GetAll( Arg.Is(u => u.ToString() == "repos/fake/repo/issues/comments"), Arg.Any>(), - Arg.Is(s => s == "application/vnd.github.squirrel-girl-preview"), + "application/vnd.github.squirrel-girl-preview", options); } @@ -115,7 +120,10 @@ public async Task RequestsCorrectUrlWithRepositoryIdWithApiOptions() await client.GetAllForRepository(1, options); - connection.Received().GetAll(Arg.Is(u => u.ToString() == "repositories/1/issues/comments"), options); + connection.Received().GetAll(Arg.Is(u => u.ToString() == "repositories/1/issues/comments"), + Arg.Any>(), + "application/vnd.github.squirrel-girl-preview", + options); } [Fact] @@ -152,7 +160,7 @@ public async Task RequestsCorrectUrl() connection.Received().GetAll( Arg.Is(u => u.ToString() == "repos/fake/repo/issues/3/comments"), Arg.Any>(), - Arg.Is(s => s == "application/vnd.github.squirrel-girl-preview"), + "application/vnd.github.squirrel-girl-preview", Args.ApiOptions); } @@ -164,7 +172,10 @@ public async Task RequestsCorrectUrlWithRepositoryId() await client.GetAllForIssue(1, 3); - connection.Received().GetAll(Arg.Is(u => u.ToString() == "repositories/1/issues/3/comments"), Args.ApiOptions); + connection.Received().GetAll(Arg.Is(u => u.ToString() == "repositories/1/issues/3/comments"), + Arg.Any>(), + "application/vnd.github.squirrel-girl-preview", + Args.ApiOptions); } [Fact] @@ -185,7 +196,7 @@ public async Task RequestsCorrectUrlWithApiOptions() connection.Received().GetAll( Arg.Is(u => u.ToString() == "repos/fake/repo/issues/3/comments"), Arg.Any>(), - Arg.Is(s => s == "application/vnd.github.squirrel-girl-preview"), + "application/vnd.github.squirrel-girl-preview", options); } @@ -204,7 +215,10 @@ public async Task RequestsCorrectUrlWithRepositoryIdWithApiOptions() await client.GetAllForIssue(1, 3, options); - connection.Received().GetAll(Arg.Is(u => u.ToString() == "repositories/1/issues/3/comments"), options); + connection.Received().GetAll(Arg.Is(u => u.ToString() == "repositories/1/issues/3/comments"), + Arg.Any>(), + "application/vnd.github.squirrel-girl-preview", + options); } [Fact] diff --git a/Octokit.Tests/Clients/IssuesClientTests.cs b/Octokit.Tests/Clients/IssuesClientTests.cs index 644685994e..981f69b6ef 100644 --- a/Octokit.Tests/Clients/IssuesClientTests.cs +++ b/Octokit.Tests/Clients/IssuesClientTests.cs @@ -33,7 +33,9 @@ public async Task RequestsCorrectUrlWithRepositoryId() await client.Get(1, 42); - connection.Received().Get(Arg.Is(u => u.ToString() == "repositories/1/issues/42")); + connection.Received().Get(Arg.Is(u => u.ToString() == "repositories/1/issues/42"), + Arg.Any>(), + "application/vnd.github.squirrel-girl-preview"); } [Fact] @@ -234,6 +236,7 @@ public async Task RequestsCorrectUrl() connection.Received().GetAll(Arg.Is(u => u.ToString() == "repos/fake/repo/issues"), Arg.Any>(), + "application/vnd.github.squirrel-girl-preview", Args.ApiOptions); } @@ -266,7 +269,10 @@ public async Task RequestsCorrectUrlWithApiOptions() await client.GetAllForRepository("fake", "repo", options); - connection.Received().GetAll(Arg.Is(u => u.ToString() == "repos/fake/repo/issues"), Arg.Any>(), options); + connection.Received().GetAll(Arg.Is(u => u.ToString() == "repos/fake/repo/issues"), + Arg.Any>(), + "application/vnd.github.squirrel-girl-preview", + options); } [Fact] @@ -286,6 +292,7 @@ public async Task RequestsCorrectUrlWithRepositoryIdWithApiOptions() connection.Received().GetAll(Arg.Is(u => u.ToString() == "repositories/1/issues"), Arg.Any>(), + "application/vnd.github.squirrel-girl-preview", options); } @@ -327,6 +334,7 @@ public async Task SendsAppropriateParametersWithRepositoryId() && d["direction"] == "asc" && d["sort"] == "created" && d["filter"] == "assigned"), + "application/vnd.github.squirrel-girl-preview", Args.ApiOptions); } @@ -354,6 +362,7 @@ public async Task SendsAppropriateParametersWithApiOptions() && d["direction"] == "asc" && d["sort"] == "created" && d["filter"] == "assigned"), + "application/vnd.github.squirrel-girl-preview", options); } @@ -381,6 +390,7 @@ public async Task SendsAppropriateParametersWithRepositoryIdWithApiOptions() && d["direction"] == "asc" && d["sort"] == "created" && d["filter"] == "assigned"), + "application/vnd.github.squirrel-girl-preview", options); } } diff --git a/Octokit.Tests/Reactive/ObservableIssuesClientTests.cs b/Octokit.Tests/Reactive/ObservableIssuesClientTests.cs index e272aa1081..7df08bb0d3 100644 --- a/Octokit.Tests/Reactive/ObservableIssuesClientTests.cs +++ b/Octokit.Tests/Reactive/ObservableIssuesClientTests.cs @@ -94,7 +94,8 @@ public void RequestsCorrectUrl() client.GetAllForRepository("fake", "repo"); gitHubClient.Connection.Received().Get>(Arg.Is(u => u.ToString() == "repos/fake/repo/issues"), - Arg.Any>(), null); + Arg.Any>(), + "application/vnd.github.squirrel-girl-preview"); } [Fact] @@ -131,7 +132,8 @@ public void RequestsCorrectUrlWithApiOptions() && d["sort"] == "created" && d["direction"] == "desc" && d["page"] == "1" - && d["per_page"] == "1"), null); + && d["per_page"] == "1"), + "application/vnd.github.squirrel-girl-preview"); } [Fact] @@ -175,7 +177,8 @@ public void SendsAppropriateParameters() && d["filter"] == "assigned" && d["state"] == "open" && d["sort"] == "created" - && d["direction"] == "asc"), null); + && d["direction"] == "asc"), + "application/vnd.github.squirrel-girl-preview"); } [Fact] @@ -223,7 +226,7 @@ public void SendsAppropriateParametersWithApiOptions() && d["direction"] == "asc" && d["page"] == "1" && d["per_page"] == "1"), - null); + "application/vnd.github.squirrel-girl-preview"); } [Fact] diff --git a/Octokit/Clients/IssueCommentsClient.cs b/Octokit/Clients/IssueCommentsClient.cs index 87e9dd7cb9..f7f2faf1fe 100644 --- a/Octokit/Clients/IssueCommentsClient.cs +++ b/Octokit/Clients/IssueCommentsClient.cs @@ -42,7 +42,7 @@ public Task Get(string owner, string name, int id) /// The issue comment id public Task Get(int repositoryId, int id) { - return ApiConnection.Get(ApiUrls.IssueComment(repositoryId, id)); + return ApiConnection.Get(ApiUrls.IssueComment(repositoryId, id), null, AcceptHeaders.ReactionsPreview); } /// @@ -95,7 +95,7 @@ public Task> GetAllForRepository(int repositoryId, A { Ensure.ArgumentNotNull(options, "options"); - return ApiConnection.GetAll(ApiUrls.IssueComments(repositoryId), options); + return ApiConnection.GetAll(ApiUrls.IssueComments(repositoryId), null, AcceptHeaders.ReactionsPreview, options); } /// @@ -152,7 +152,7 @@ public Task> GetAllForIssue(int repositoryId, int nu { Ensure.ArgumentNotNull(options, "options"); - return ApiConnection.GetAll(ApiUrls.IssueComments(repositoryId, number), options); + return ApiConnection.GetAll(ApiUrls.IssueComments(repositoryId, number), null, AcceptHeaders.ReactionsPreview, options); } /// diff --git a/Octokit/Clients/IssuesClient.cs b/Octokit/Clients/IssuesClient.cs index 614ea3db83..f085acb14a 100644 --- a/Octokit/Clients/IssuesClient.cs +++ b/Octokit/Clients/IssuesClient.cs @@ -78,7 +78,7 @@ public Task Get(string owner, string name, int number) /// The issue number public Task Get(int repositoryId, int number) { - return ApiConnection.Get(ApiUrls.Issue(repositoryId, number)); + return ApiConnection.Get(ApiUrls.Issue(repositoryId, number), null, AcceptHeaders.ReactionsPreview); } /// @@ -393,7 +393,7 @@ public Task> GetAllForRepository(int repositoryId, Reposito Ensure.ArgumentNotNull(request, "request"); Ensure.ArgumentNotNull(options, "options"); - return ApiConnection.GetAll(ApiUrls.Issues(repositoryId), request.ToParametersDictionary(), options); + return ApiConnection.GetAll(ApiUrls.Issues(repositoryId), request.ToParametersDictionary(), AcceptHeaders.ReactionsPreview, options); } ///