Skip to content

Commit

Permalink
Fixup unit tests wth preview accepts header
Browse files Browse the repository at this point in the history
Also applied preview header to a couple of repositoryId based calls that were added by another PR
  • Loading branch information
ryangribble committed Jul 7, 2016
1 parent 43411b8 commit 1185da2
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 22 deletions.
36 changes: 25 additions & 11 deletions Octokit.Tests/Clients/IssueCommentsClientTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ public async Task RequestsCorrectUrl()

connection.Received().Get<IssueComment>(
Arg.Is<Uri>(u => u.ToString() == "repos/fake/repo/issues/comments/42"),
Arg.Any<Dictionary<string, string>>(),
Arg.Is<string>(s => s == "application/vnd.github.squirrel-girl-preview"));
Arg.Any<Dictionary<string, string>>(),
"application/vnd.github.squirrel-girl-preview");
}

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

await client.Get(1, 42);

connection.Received().Get<IssueComment>(Arg.Is<Uri>(u => u.ToString() == "repositories/1/issues/comments/42"));
connection.Received().Get<IssueComment>(Arg.Is<Uri>(u => u.ToString() == "repositories/1/issues/comments/42"),
Arg.Any<Dictionary<string, string>>(),
"application/vnd.github.squirrel-girl-preview");
}

[Fact]
Expand Down Expand Up @@ -63,7 +65,7 @@ public async Task RequestsCorrectUrl()
connection.Received().GetAll<IssueComment>(
Arg.Is<Uri>(u => u.ToString() == "repos/fake/repo/issues/comments"),
Arg.Any<Dictionary<string, string>>(),
Arg.Is<string>(s => s == "application/vnd.github.squirrel-girl-preview"),
"application/vnd.github.squirrel-girl-preview",
Args.ApiOptions);
}

Expand All @@ -75,7 +77,10 @@ public async Task RequestsCorrectUrlWithRepositoryId()

await client.GetAllForRepository(1);

connection.Received().GetAll<IssueComment>(Arg.Is<Uri>(u => u.ToString() == "repositories/1/issues/comments"), Args.ApiOptions);
connection.Received().GetAll<IssueComment>(Arg.Is<Uri>(u => u.ToString() == "repositories/1/issues/comments"),
Arg.Any<Dictionary<string, string>>(),
"application/vnd.github.squirrel-girl-preview",
Args.ApiOptions);
}

[Fact]
Expand All @@ -96,7 +101,7 @@ public async Task RequestsCorrectUrlWithApiOptions()
connection.Received().GetAll<IssueComment>(
Arg.Is<Uri>(u => u.ToString() == "repos/fake/repo/issues/comments"),
Arg.Any<Dictionary<string, string>>(),
Arg.Is<string>(s => s == "application/vnd.github.squirrel-girl-preview"),
"application/vnd.github.squirrel-girl-preview",
options);
}

Expand All @@ -115,7 +120,10 @@ public async Task RequestsCorrectUrlWithRepositoryIdWithApiOptions()

await client.GetAllForRepository(1, options);

connection.Received().GetAll<IssueComment>(Arg.Is<Uri>(u => u.ToString() == "repositories/1/issues/comments"), options);
connection.Received().GetAll<IssueComment>(Arg.Is<Uri>(u => u.ToString() == "repositories/1/issues/comments"),
Arg.Any<Dictionary<string, string>>(),
"application/vnd.github.squirrel-girl-preview",
options);
}

[Fact]
Expand Down Expand Up @@ -152,7 +160,7 @@ public async Task RequestsCorrectUrl()
connection.Received().GetAll<IssueComment>(
Arg.Is<Uri>(u => u.ToString() == "repos/fake/repo/issues/3/comments"),
Arg.Any<Dictionary<string, string>>(),
Arg.Is<string>(s => s == "application/vnd.github.squirrel-girl-preview"),
"application/vnd.github.squirrel-girl-preview",
Args.ApiOptions);
}

Expand All @@ -164,7 +172,10 @@ public async Task RequestsCorrectUrlWithRepositoryId()

await client.GetAllForIssue(1, 3);

connection.Received().GetAll<IssueComment>(Arg.Is<Uri>(u => u.ToString() == "repositories/1/issues/3/comments"), Args.ApiOptions);
connection.Received().GetAll<IssueComment>(Arg.Is<Uri>(u => u.ToString() == "repositories/1/issues/3/comments"),
Arg.Any<Dictionary<string, string>>(),
"application/vnd.github.squirrel-girl-preview",
Args.ApiOptions);
}

[Fact]
Expand All @@ -185,7 +196,7 @@ public async Task RequestsCorrectUrlWithApiOptions()
connection.Received().GetAll<IssueComment>(
Arg.Is<Uri>(u => u.ToString() == "repos/fake/repo/issues/3/comments"),
Arg.Any<Dictionary<string, string>>(),
Arg.Is<string>(s => s == "application/vnd.github.squirrel-girl-preview"),
"application/vnd.github.squirrel-girl-preview",
options);
}

Expand All @@ -204,7 +215,10 @@ public async Task RequestsCorrectUrlWithRepositoryIdWithApiOptions()

await client.GetAllForIssue(1, 3, options);

connection.Received().GetAll<IssueComment>(Arg.Is<Uri>(u => u.ToString() == "repositories/1/issues/3/comments"), options);
connection.Received().GetAll<IssueComment>(Arg.Is<Uri>(u => u.ToString() == "repositories/1/issues/3/comments"),
Arg.Any<Dictionary<string, string>>(),
"application/vnd.github.squirrel-girl-preview",
options);
}

[Fact]
Expand Down
14 changes: 12 additions & 2 deletions Octokit.Tests/Clients/IssuesClientTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,9 @@ public async Task RequestsCorrectUrlWithRepositoryId()

await client.Get(1, 42);

connection.Received().Get<Issue>(Arg.Is<Uri>(u => u.ToString() == "repositories/1/issues/42"));
connection.Received().Get<Issue>(Arg.Is<Uri>(u => u.ToString() == "repositories/1/issues/42"),
Arg.Any<Dictionary<string, string>>(),
"application/vnd.github.squirrel-girl-preview");
}

[Fact]
Expand Down Expand Up @@ -234,6 +236,7 @@ public async Task RequestsCorrectUrl()

connection.Received().GetAll<Issue>(Arg.Is<Uri>(u => u.ToString() == "repos/fake/repo/issues"),
Arg.Any<Dictionary<string, string>>(),
"application/vnd.github.squirrel-girl-preview",
Args.ApiOptions);
}

Expand Down Expand Up @@ -266,7 +269,10 @@ public async Task RequestsCorrectUrlWithApiOptions()

await client.GetAllForRepository("fake", "repo", options);

connection.Received().GetAll<Issue>(Arg.Is<Uri>(u => u.ToString() == "repos/fake/repo/issues"), Arg.Any<Dictionary<string, string>>(), options);
connection.Received().GetAll<Issue>(Arg.Is<Uri>(u => u.ToString() == "repos/fake/repo/issues"),
Arg.Any<Dictionary<string, string>>(),
"application/vnd.github.squirrel-girl-preview",
options);
}

[Fact]
Expand All @@ -286,6 +292,7 @@ public async Task RequestsCorrectUrlWithRepositoryIdWithApiOptions()

connection.Received().GetAll<Issue>(Arg.Is<Uri>(u => u.ToString() == "repositories/1/issues"),
Arg.Any<Dictionary<string, string>>(),
"application/vnd.github.squirrel-girl-preview",
options);
}

Expand Down Expand Up @@ -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);
}

Expand Down Expand Up @@ -354,6 +362,7 @@ public async Task SendsAppropriateParametersWithApiOptions()
&& d["direction"] == "asc"
&& d["sort"] == "created"
&& d["filter"] == "assigned"),
"application/vnd.github.squirrel-girl-preview",
options);
}

Expand Down Expand Up @@ -381,6 +390,7 @@ public async Task SendsAppropriateParametersWithRepositoryIdWithApiOptions()
&& d["direction"] == "asc"
&& d["sort"] == "created"
&& d["filter"] == "assigned"),
"application/vnd.github.squirrel-girl-preview",
options);
}
}
Expand Down
11 changes: 7 additions & 4 deletions Octokit.Tests/Reactive/ObservableIssuesClientTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,8 @@ public void RequestsCorrectUrl()
client.GetAllForRepository("fake", "repo");

gitHubClient.Connection.Received().Get<List<Issue>>(Arg.Is<Uri>(u => u.ToString() == "repos/fake/repo/issues"),
Arg.Any<IDictionary<string, string>>(), null);
Arg.Any<IDictionary<string, string>>(),
"application/vnd.github.squirrel-girl-preview");
}

[Fact]
Expand Down Expand Up @@ -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]
Expand Down Expand Up @@ -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]
Expand Down Expand Up @@ -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]
Expand Down
6 changes: 3 additions & 3 deletions Octokit/Clients/IssueCommentsClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public Task<IssueComment> Get(string owner, string name, int id)
/// <param name="id">The issue comment id</param>
public Task<IssueComment> Get(int repositoryId, int id)
{
return ApiConnection.Get<IssueComment>(ApiUrls.IssueComment(repositoryId, id));
return ApiConnection.Get<IssueComment>(ApiUrls.IssueComment(repositoryId, id), null, AcceptHeaders.ReactionsPreview);
}

/// <summary>
Expand Down Expand Up @@ -95,7 +95,7 @@ public Task<IReadOnlyList<IssueComment>> GetAllForRepository(int repositoryId, A
{
Ensure.ArgumentNotNull(options, "options");

return ApiConnection.GetAll<IssueComment>(ApiUrls.IssueComments(repositoryId), options);
return ApiConnection.GetAll<IssueComment>(ApiUrls.IssueComments(repositoryId), null, AcceptHeaders.ReactionsPreview, options);
}

/// <summary>
Expand Down Expand Up @@ -152,7 +152,7 @@ public Task<IReadOnlyList<IssueComment>> GetAllForIssue(int repositoryId, int nu
{
Ensure.ArgumentNotNull(options, "options");

return ApiConnection.GetAll<IssueComment>(ApiUrls.IssueComments(repositoryId, number), options);
return ApiConnection.GetAll<IssueComment>(ApiUrls.IssueComments(repositoryId, number), null, AcceptHeaders.ReactionsPreview, options);
}

/// <summary>
Expand Down
4 changes: 2 additions & 2 deletions Octokit/Clients/IssuesClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ public Task<Issue> Get(string owner, string name, int number)
/// <param name="number">The issue number</param>
public Task<Issue> Get(int repositoryId, int number)
{
return ApiConnection.Get<Issue>(ApiUrls.Issue(repositoryId, number));
return ApiConnection.Get<Issue>(ApiUrls.Issue(repositoryId, number), null, AcceptHeaders.ReactionsPreview);
}

/// <summary>
Expand Down Expand Up @@ -393,7 +393,7 @@ public Task<IReadOnlyList<Issue>> GetAllForRepository(int repositoryId, Reposito
Ensure.ArgumentNotNull(request, "request");
Ensure.ArgumentNotNull(options, "options");

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

/// <summary>
Expand Down

0 comments on commit 1185da2

Please sign in to comment.