Skip to content

Commit

Permalink
gets tests passing again
Browse files Browse the repository at this point in the history
  • Loading branch information
shiftkey committed Jul 7, 2016
1 parent e1c97fe commit 7e94dbc
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 31 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,10 @@ public IObservable<PullRequestReviewComment> GetAllForRepository(int repositoryI
Ensure.ArgumentNotNull(request, "request");
Ensure.ArgumentNotNull(options, "options");

return _connection.GetAndFlattenAllPages<PullRequestReviewComment>(ApiUrls.PullRequestReviewCommentsRepository(repositoryId), request.ToParametersDictionary(),
return _connection.GetAndFlattenAllPages<PullRequestReviewComment>(
ApiUrls.PullRequestReviewCommentsRepository(repositoryId),
request.ToParametersDictionary(),
AcceptHeaders.ReactionsPreview,
options);
}

Expand Down
20 changes: 15 additions & 5 deletions Octokit.Tests/Clients/PullRequestReviewCommentsClientTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,9 @@ public async Task RequestsCorrectUrl()
Arg.Is<Dictionary<string, string>>(d => d.Count == 3
&& d["direction"] == "desc"
&& d["since"] == "2013-11-15T11:43:01Z"
&& d["sort"] == "updated"), Args.ApiOptions);
&& d["sort"] == "updated"),
"application/vnd.github.squirrel-girl-preview",
Args.ApiOptions);
}

[Fact]
Expand Down Expand Up @@ -251,7 +253,9 @@ public async Task RequestsCorrectUrlWithApiOptions()
Arg.Is<Dictionary<string, string>>(d => d.Count == 3
&& d["direction"] == "desc"
&& d["since"] == "2013-11-15T11:43:01Z"
&& d["sort"] == "updated"), options);
&& d["sort"] == "updated"),
"application/vnd.github.squirrel-girl-preview",
options);
}

[Fact]
Expand Down Expand Up @@ -295,7 +299,9 @@ public async Task RequestsCorrectUrlWithoutSelectedSortingArguments()
connection.Received().GetAll<PullRequestReviewComment>(Arg.Is<Uri>(u => u.ToString() == "repos/owner/name/pulls/comments"),
Arg.Is<Dictionary<string, string>>(d => d.Count == 2
&& d["direction"] == "asc"
&& d["sort"] == "created"), Args.ApiOptions);
&& d["sort"] == "created"),
"application/vnd.github.squirrel-girl-preview",
Args.ApiOptions);
}

[Fact]
Expand Down Expand Up @@ -331,7 +337,9 @@ public async Task RequestsCorrectUrlWithoutSelectedSortingArgumentsWithApiOption
connection.Received().GetAll<PullRequestReviewComment>(Arg.Is<Uri>(u => u.ToString() == "repos/owner/name/pulls/comments"),
Arg.Is<Dictionary<string, string>>(d => d.Count == 2
&& d["direction"] == "asc"
&& d["sort"] == "created"), options);
&& d["sort"] == "created"),
"application/vnd.github.squirrel-girl-preview",
options);
}

[Fact]
Expand Down Expand Up @@ -410,7 +418,9 @@ public void RequestsCorrectUrl()

client.GetComment("owner", "name", 53);

connection.Received().Get<PullRequestReviewComment>(Arg.Is<Uri>(u => u.ToString() == "repos/fakeOwner/fakeRepoName/pulls/comments/53"), Arg.Any<Dictionary<string, string>>(),
connection.Received().Get<PullRequestReviewComment>(
Arg.Is<Uri>(u => u.ToString() == "repos/owner/name/pulls/comments/53"),
Arg.Any<Dictionary<string, string>>(),
"application/vnd.github.squirrel-girl-preview");
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,21 +125,22 @@ public async Task RequestsCorrectUrlMulti()
);

var gitHubClient = Substitute.For<IGitHubClient>();
gitHubClient.Connection.Get<List<PullRequestReviewComment>>(firstPageUrl, Args.EmptyDictionary, "application/vnd.github.squirrel-girl-preview")
var acceptHeader = "application/vnd.github.squirrel-girl-preview";
gitHubClient.Connection.Get<List<PullRequestReviewComment>>(firstPageUrl, Args.EmptyDictionary, acceptHeader)
.Returns(Task.Factory.StartNew<IApiResponse<List<PullRequestReviewComment>>>(() => firstPageResponse));
gitHubClient.Connection.Get<List<PullRequestReviewComment>>(secondPageUrl, Args.EmptyDictionary, "application/vnd.github.squirrel-girl-preview")
gitHubClient.Connection.Get<List<PullRequestReviewComment>>(secondPageUrl, Args.EmptyDictionary, acceptHeader)
.Returns(Task.Factory.StartNew<IApiResponse<List<PullRequestReviewComment>>>(() => secondPageResponse));
gitHubClient.Connection.Get<List<PullRequestReviewComment>>(thirdPageUrl, Args.EmptyDictionary, "application/vnd.github.squirrel-girl-preview")
gitHubClient.Connection.Get<List<PullRequestReviewComment>>(thirdPageUrl, Args.EmptyDictionary, acceptHeader)
.Returns(Task.Factory.StartNew<IApiResponse<List<PullRequestReviewComment>>>(() => lastPageResponse));

var client = new ObservablePullRequestReviewCommentsClient(gitHubClient);

var results = await client.GetAll("owner", "name", 7).ToArray();

Assert.Equal(7, results.Length);
gitHubClient.Connection.Received(1).Get<List<PullRequestReviewComment>>(firstPageUrl, Args.EmptyDictionary, null);
gitHubClient.Connection.Received(1).Get<List<PullRequestReviewComment>>(secondPageUrl, Args.EmptyDictionary, null);
gitHubClient.Connection.Received(1).Get<List<PullRequestReviewComment>>(thirdPageUrl, Args.EmptyDictionary, null);
gitHubClient.Connection.Received(1).Get<List<PullRequestReviewComment>>(firstPageUrl, Args.EmptyDictionary, acceptHeader);
gitHubClient.Connection.Received(1).Get<List<PullRequestReviewComment>>(secondPageUrl, Args.EmptyDictionary, acceptHeader);
gitHubClient.Connection.Received(1).Get<List<PullRequestReviewComment>>(thirdPageUrl, Args.EmptyDictionary, acceptHeader);
}

[Fact]
Expand Down Expand Up @@ -178,6 +179,8 @@ public async Task RequestsCorrectUrlMultiWithRepositoryId()
}
);

var acceptHeader = "application/vnd.github.squirrel-girl-preview";

var gitHubClient = Substitute.For<IGitHubClient>();
gitHubClient.Connection.Get<List<PullRequestReviewComment>>(firstPageUrl, Args.EmptyDictionary, null)
.Returns(Task.Factory.StartNew<IApiResponse<List<PullRequestReviewComment>>>(() => firstPageResponse));
Expand All @@ -191,9 +194,9 @@ public async Task RequestsCorrectUrlMultiWithRepositoryId()
var results = await client.GetAll(1, 7).ToArray();

Assert.Equal(7, results.Length);
gitHubClient.Connection.Received(1).Get<List<PullRequestReviewComment>>(firstPageUrl, Args.EmptyDictionary, "application/vnd.github.squirrel-girl-preview");
gitHubClient.Connection.Received(1).Get<List<PullRequestReviewComment>>(secondPageUrl, Args.EmptyDictionary, "application/vnd.github.squirrel-girl-preview");
gitHubClient.Connection.Received(1).Get<List<PullRequestReviewComment>>(thirdPageUrl, Args.EmptyDictionary, "application/vnd.github.squirrel-girl-preview");
gitHubClient.Connection.Received(1).Get<List<PullRequestReviewComment>>(firstPageUrl, Args.EmptyDictionary, null);
gitHubClient.Connection.Received(1).Get<List<PullRequestReviewComment>>(secondPageUrl, Args.EmptyDictionary, null);
gitHubClient.Connection.Received(1).Get<List<PullRequestReviewComment>>(thirdPageUrl, Args.EmptyDictionary, null);
}

[Fact]
Expand Down Expand Up @@ -343,22 +346,23 @@ public async Task RequestsCorrectUrlMulti()
);

var gitHubClient = Substitute.For<IGitHubClient>();
var previewAcceptHeader = "application/vnd.github.squirrel-girl-preview";

gitHubClient.Connection.Get<List<PullRequestReviewComment>>(firstPageUrl,
Arg.Is<Dictionary<string, string>>(d => d.Count == 3
&& d["direction"] == "desc"
&& d["since"] == "2013-11-15T11:43:01Z"
&& d["sort"] == "updated"), null)
&& d["sort"] == "updated"), previewAcceptHeader)
.Returns(Task.Factory.StartNew<IApiResponse<List<PullRequestReviewComment>>>(() => firstPageResponse));
gitHubClient.Connection.Get<List<PullRequestReviewComment>>(secondPageUrl, Arg.Is<Dictionary<string, string>>(d => d.Count == 3
&& d["direction"] == "desc"
&& d["since"] == "2013-11-15T11:43:01Z"
&& d["sort"] == "updated"), null)
&& d["sort"] == "updated"), previewAcceptHeader)
.Returns(Task.Factory.StartNew<IApiResponse<List<PullRequestReviewComment>>>(() => secondPageResponse));
gitHubClient.Connection.Get<List<PullRequestReviewComment>>(thirdPageUrl, Arg.Is<Dictionary<string, string>>(d => d.Count == 3
&& d["direction"] == "desc"
&& d["since"] == "2013-11-15T11:43:01Z"
&& d["sort"] == "updated"), null)
&& d["sort"] == "updated"), previewAcceptHeader)
.Returns(Task.Factory.StartNew<IApiResponse<List<PullRequestReviewComment>>>(() => lastPageResponse));

var client = new ObservablePullRequestReviewCommentsClient(gitHubClient);
Expand All @@ -377,15 +381,15 @@ public async Task RequestsCorrectUrlMulti()
Arg.Is<Dictionary<string, string>>(d => d.Count == 3
&& d["direction"] == "desc"
&& d["since"] == "2013-11-15T11:43:01Z"
&& d["sort"] == "updated"), null);
&& d["sort"] == "updated"), previewAcceptHeader);
gitHubClient.Connection.Received(1).Get<List<PullRequestReviewComment>>(secondPageUrl, Arg.Is<Dictionary<string, string>>(d => d.Count == 3
&& d["direction"] == "desc"
&& d["since"] == "2013-11-15T11:43:01Z"
&& d["sort"] == "updated"), null);
&& d["sort"] == "updated"), previewAcceptHeader);
gitHubClient.Connection.Received(1).Get<List<PullRequestReviewComment>>(thirdPageUrl, Arg.Is<Dictionary<string, string>>(d => d.Count == 3
&& d["direction"] == "desc"
&& d["since"] == "2013-11-15T11:43:01Z"
&& d["sort"] == "updated"), null);
&& d["sort"] == "updated"), previewAcceptHeader);
}

[Fact]
Expand Down Expand Up @@ -568,18 +572,20 @@ public async Task RequestsCorrectUrlWithoutSelectedSortingArgumentsMulti()

var gitHubClient = Substitute.For<IGitHubClient>();

var previewAcceptHeader = "application/vnd.github.squirrel-girl-preview";

gitHubClient.Connection.Get<List<PullRequestReviewComment>>(firstPageUrl,
Arg.Is<Dictionary<string, string>>(d => d.Count == 2
&& d["direction"] == "asc"
&& d["sort"] == "created"), null)
&& d["sort"] == "created"), previewAcceptHeader)
.Returns(Task.Factory.StartNew<IApiResponse<List<PullRequestReviewComment>>>(() => firstPageResponse));
gitHubClient.Connection.Get<List<PullRequestReviewComment>>(secondPageUrl, Arg.Is<Dictionary<string, string>>(d => d.Count == 2
&& d["direction"] == "asc"
&& d["sort"] == "created"), null)
&& d["sort"] == "created"), previewAcceptHeader)
.Returns(Task.Factory.StartNew<IApiResponse<List<PullRequestReviewComment>>>(() => secondPageResponse));
gitHubClient.Connection.Get<List<PullRequestReviewComment>>(thirdPageUrl, Arg.Is<Dictionary<string, string>>(d => d.Count == 2
&& d["direction"] == "asc"
&& d["sort"] == "created"), null)
&& d["sort"] == "created"), previewAcceptHeader)
.Returns(Task.Factory.StartNew<IApiResponse<List<PullRequestReviewComment>>>(() => lastPageResponse));

var client = new ObservablePullRequestReviewCommentsClient(gitHubClient);
Expand All @@ -590,13 +596,13 @@ public async Task RequestsCorrectUrlWithoutSelectedSortingArgumentsMulti()
gitHubClient.Connection.Received(1).Get<List<PullRequestReviewComment>>(firstPageUrl,
Arg.Is<Dictionary<string, string>>(d => d.Count == 2
&& d["direction"] == "asc"
&& d["sort"] == "created"), null);
&& d["sort"] == "created"), previewAcceptHeader);
gitHubClient.Connection.Received(1).Get<List<PullRequestReviewComment>>(secondPageUrl, Arg.Is<Dictionary<string, string>>(d => d.Count == 2
&& d["direction"] == "asc"
&& d["sort"] == "created"), null);
&& d["sort"] == "created"), previewAcceptHeader);
gitHubClient.Connection.Received(1).Get<List<PullRequestReviewComment>>(thirdPageUrl, Arg.Is<Dictionary<string, string>>(d => d.Count == 2
&& d["direction"] == "asc"
&& d["sort"] == "created"), null);
&& d["sort"] == "created"), previewAcceptHeader);
}

[Fact]
Expand Down Expand Up @@ -660,10 +666,12 @@ public async Task RequestsCorrectUrlWithoutSelectedSortingArgumentsMultiWithRepo
gitHubClient.Connection.Received(1).Get<List<PullRequestReviewComment>>(firstPageUrl,
Arg.Is<Dictionary<string, string>>(d => d.Count == 2
&& d["direction"] == "asc"
&& d["sort"] == "created"), "application/vnd.github.squirrel-girl-preview");
&& d["sort"] == "created"),
"application/vnd.github.squirrel-girl-preview");
gitHubClient.Connection.Received(1).Get<List<PullRequestReviewComment>>(secondPageUrl, Arg.Is<Dictionary<string, string>>(d => d.Count == 2
&& d["direction"] == "asc"
&& d["sort"] == "created"), "application/vnd.github.squirrel-girl-preview");
&& d["sort"] == "created"),
"application/vnd.github.squirrel-girl-preview");
gitHubClient.Connection.Received(1).Get<List<PullRequestReviewComment>>(thirdPageUrl, Arg.Is<Dictionary<string, string>>(d => d.Count == 2
&& d["direction"] == "asc"
&& d["sort"] == "created"), "application/vnd.github.squirrel-girl-preview");
Expand Down
4 changes: 2 additions & 2 deletions Octokit/Clients/PullRequestReviewCommentsClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ public Task<IReadOnlyList<PullRequestReviewComment>> GetAllForRepository(int rep
Ensure.ArgumentNotNull(request, "request");
Ensure.ArgumentNotNull(options, "options");

return ApiConnection.GetAll<PullRequestReviewComment>(ApiUrls.PullRequestReviewCommentsRepository(repositoryId), request.ToParametersDictionary(), options);
return ApiConnection.GetAll<PullRequestReviewComment>(ApiUrls.PullRequestReviewCommentsRepository(repositoryId), request.ToParametersDictionary(), AcceptHeaders.ReactionsPreview, options);
}

/// <summary>
Expand All @@ -201,7 +201,7 @@ public Task<PullRequestReviewComment> GetComment(string owner, string name, int
Ensure.ArgumentNotNullOrEmptyString(owner, "owner");
Ensure.ArgumentNotNullOrEmptyString(name, "name");

return ApiConnection.Get<PullRequestReviewComment>(ApiUrls.PullRequestReviewComment(owner, name, number), null, AcceptHeaders.ReactionsPreview);
return ApiConnection.Get<PullRequestReviewComment>(ApiUrls.PullRequestReviewComment(owner, name, number), new Dictionary<string, string>(), AcceptHeaders.ReactionsPreview);
}

/// <summary>
Expand Down

0 comments on commit 7e94dbc

Please sign in to comment.