Skip to content

Commit

Permalink
fix language with spaces giving wrong results (#2038)
Browse files Browse the repository at this point in the history
  • Loading branch information
Dagizmo authored and shiftkey committed Nov 13, 2019
1 parent f61654a commit fd6bca9
Show file tree
Hide file tree
Showing 9 changed files with 18 additions and 18 deletions.
20 changes: 10 additions & 10 deletions Octokit.Tests/Clients/SearchClientTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -200,13 +200,13 @@ public void TestingTheLanguageQualifier()
{
var connection = Substitute.For<IApiConnection>();
var client = new SearchClient(connection);
//get users who have mostly repos where language is Ruby
//get users who have mostly repos where language is Literate Haskell
var request = new SearchUsersRequest("github");
request.Language = Language.Ruby;
request.Language = Language.LiterateHaskell;
client.SearchUsers(request);
connection.Received().Get<SearchUsersResult>(
Arg.Is<Uri>(u => u.ToString() == "search/users"),
Arg.Is<Dictionary<string, string>>(d => d["q"] == "github+language:Ruby"));
Arg.Is<Dictionary<string, string>>(d => d["q"] == "github+language:\"Literate Haskell\""));
}

[Fact]
Expand Down Expand Up @@ -462,12 +462,12 @@ public void TestingTheLangaugeQualifier()
{
var connection = Substitute.For<IApiConnection>();
var client = new SearchClient(connection);
//get repos who's language is Ruby
//get repos who's language is Literate Haskell
var request = new SearchRepositoriesRequest("github");
request.Language = Language.Ruby;
request.Language = Language.LiterateHaskell;
client.SearchRepo(request);
connection.Received().Get<SearchRepositoryResult>(Arg.Is<Uri>(u => u.ToString() == "search/repositories"),
Arg.Is<Dictionary<string, string>>(d => d["q"] == "github+language:ruby"));
Arg.Is<Dictionary<string, string>>(d => d["q"] == "github+language:\"Literate Haskell\""));
}

[Fact]
Expand Down Expand Up @@ -986,13 +986,13 @@ public void TestingTheLanguageQualifier()
var connection = Substitute.For<IApiConnection>();
var client = new SearchClient(connection);
var request = new SearchIssuesRequest("something");
request.Language = Language.CSharp;
request.Language = Language.LiterateHaskell;

client.SearchIssues(request);

connection.Received().Get<SearchIssuesResult>(
Arg.Is<Uri>(u => u.ToString() == "search/issues"),
Arg.Is<Dictionary<string, string>>(d => d["q"] == "something+language:CSharp"));
Arg.Is<Dictionary<string, string>>(d => d["q"] == "something+language:\"Literate Haskell\""));
}

[Fact]
Expand Down Expand Up @@ -1682,13 +1682,13 @@ public void TestingTheLanguageQualifier()
var connection = Substitute.For<IApiConnection>();
var client = new SearchClient(connection);
var request = new SearchCodeRequest("something");
request.Language = Language.CSharp;
request.Language = Language.LiterateHaskell;

client.SearchCode(request);

connection.Received().Get<SearchCodeResult>(
Arg.Is<Uri>(u => u.ToString() == "search/code"),
Arg.Is<Dictionary<string, string>>(d => d["q"] == "something+language:CSharp"));
Arg.Is<Dictionary<string, string>>(d => d["q"] == "something+language:\"Literate Haskell\""));
}

[Fact]
Expand Down
2 changes: 1 addition & 1 deletion Octokit.Tests/Models/SearchIssuesRequestExclusionsTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public void HandlesLanguageAttributeCorrectly()

request.Language = Language.CSharp;

Assert.Contains("-language:CSharp", request.MergedQualifiers());
Assert.Contains("-language:\"CSharp\"", request.MergedQualifiers());
}

[Fact]
Expand Down
2 changes: 1 addition & 1 deletion Octokit.Tests/Models/SearchIssuesRequestTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ public void HandlesLanguageAttributeCorrectly()
Assert.DoesNotContain(request.MergedQualifiers(), x => x.Contains("language:"));

request.Language = Language.CSharp;
Assert.Contains("language:CSharp", request.MergedQualifiers());
Assert.Contains("language:\"CSharp\"", request.MergedQualifiers());
}

[Fact]
Expand Down
2 changes: 1 addition & 1 deletion Octokit.Tests/Models/SearchRepositoryRequestTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public void LanguageUsesParameterTranslation()
{
var request = new SearchRepositoriesRequest() { Language = Language.CPlusPlus };
var result = request.MergedQualifiers();
Assert.Contains(result, x => string.Equals(x, "language:cpp"));
Assert.Contains(result, x => string.Equals(x, "language:\"cpp\""));
}
}
}
2 changes: 1 addition & 1 deletion Octokit/Models/Request/SearchCodeRequest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ public override IReadOnlyList<string> MergedQualifiers()

if (Language != null)
{
parameters.Add(string.Format(CultureInfo.InvariantCulture, "language:{0}", Language.ToParameter()));
parameters.Add(string.Format(CultureInfo.InvariantCulture, "language:\"{0}\"", Language.ToParameter()));
}

if (Forks != null)
Expand Down
2 changes: 1 addition & 1 deletion Octokit/Models/Request/SearchIssuesRequest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,7 @@ public override IReadOnlyList<string> MergedQualifiers()

if (Language != null)
{
parameters.Add(string.Format(CultureInfo.InvariantCulture, "language:{0}", Language.ToParameter()));
parameters.Add(string.Format(CultureInfo.InvariantCulture, "language:\"{0}\"", Language.ToParameter()));
}

if (Is != null)
Expand Down
2 changes: 1 addition & 1 deletion Octokit/Models/Request/SearchIssuesRequestExclusions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ public IReadOnlyList<string> MergedQualifiers()

if (Language != null)
{
parameters.Add(string.Format(CultureInfo.InvariantCulture, "-language:{0}", Language.ToParameter()));
parameters.Add(string.Format(CultureInfo.InvariantCulture, "-language:\"{0}\"", Language.ToParameter()));
}

if (Status.HasValue)
Expand Down
2 changes: 1 addition & 1 deletion Octokit/Models/Request/SearchRepositoriesRequest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ public override IReadOnlyList<string> MergedQualifiers()

if (Language != null)
{
parameters.Add(string.Format(CultureInfo.InvariantCulture, "language:{0}", Language.ToParameter()));
parameters.Add(string.Format(CultureInfo.InvariantCulture, "language:\"{0}\"", Language.ToParameter()));
}

if (User.IsNotBlank())
Expand Down
2 changes: 1 addition & 1 deletion Octokit/Models/Request/SearchUsersRequest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ public override IReadOnlyList<string> MergedQualifiers()

if (Language != null)
{
parameters.Add(string.Format(CultureInfo.InvariantCulture, "language:{0}", Language));
parameters.Add(string.Format(CultureInfo.InvariantCulture, "language:\"{0}\"", Language.ToParameter()));
}

if (Created != null)
Expand Down

0 comments on commit fd6bca9

Please sign in to comment.