mirror of
https://github.com/zoriya/octokit.net.git
synced 2026-06-04 19:26:51 +00:00
Fix forks qualifier in repo search and add tests (#1680)
This commit is contained in:
@@ -23,6 +23,30 @@ public class SearchClientTests
|
||||
Assert.NotEmpty(repos.Items);
|
||||
}
|
||||
|
||||
[IntegrationTest]
|
||||
public async Task SearchForForkedRepositories()
|
||||
{
|
||||
var request = new SearchRepositoriesRequest("octokit")
|
||||
{
|
||||
Fork = ForkQualifier.IncludeForks
|
||||
};
|
||||
var repos = await _gitHubClient.Search.SearchRepo(request);
|
||||
|
||||
Assert.True(repos.Items.Any(x => x.Fork));
|
||||
}
|
||||
|
||||
[IntegrationTest]
|
||||
public async Task SearchForOnlyForkedRepositories()
|
||||
{
|
||||
var request = new SearchRepositoriesRequest("octokit")
|
||||
{
|
||||
Fork = ForkQualifier.OnlyForks
|
||||
};
|
||||
var repos = await _gitHubClient.Search.SearchRepo(request);
|
||||
|
||||
Assert.True(repos.Items.All(x => x.Fork));
|
||||
}
|
||||
|
||||
[IntegrationTest]
|
||||
public async Task SearchForGitHub()
|
||||
{
|
||||
|
||||
@@ -428,7 +428,7 @@ namespace Octokit.Tests.Clients
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void TestingTheForkQualifier()
|
||||
public void TestingTheIncludeForkQualifier()
|
||||
{
|
||||
var connection = Substitute.For<IApiConnection>();
|
||||
var client = new SearchClient(connection);
|
||||
@@ -437,7 +437,20 @@ namespace Octokit.Tests.Clients
|
||||
request.Fork = ForkQualifier.IncludeForks;
|
||||
client.SearchRepo(request);
|
||||
connection.Received().Get<SearchRepositoryResult>(Arg.Is<Uri>(u => u.ToString() == "search/repositories"),
|
||||
Arg.Is<Dictionary<string, string>>(d => d["q"] == "github+fork:IncludeForks"));
|
||||
Arg.Is<Dictionary<string, string>>(d => d["q"] == "github+fork:true"));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void TestingTheOnlyForkQualifier()
|
||||
{
|
||||
var connection = Substitute.For<IApiConnection>();
|
||||
var client = new SearchClient(connection);
|
||||
//search repos that contains rails and forks are included in the search
|
||||
var request = new SearchRepositoriesRequest("github");
|
||||
request.Fork = ForkQualifier.OnlyForks;
|
||||
client.SearchRepo(request);
|
||||
connection.Received().Get<SearchRepositoryResult>(Arg.Is<Uri>(u => u.ToString() == "search/repositories"),
|
||||
Arg.Is<Dictionary<string, string>>(d => d["q"] == "github+fork:only"));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
||||
@@ -133,7 +133,7 @@ namespace Octokit
|
||||
|
||||
if (Fork != null)
|
||||
{
|
||||
parameters.Add(string.Format(CultureInfo.InvariantCulture, "fork:{0}", Fork));
|
||||
parameters.Add(string.Format(CultureInfo.InvariantCulture, "fork:{0}", Fork.ToParameter()));
|
||||
}
|
||||
|
||||
if (Stars != null)
|
||||
@@ -780,12 +780,12 @@ namespace Octokit
|
||||
/// <summary>
|
||||
/// only search for forked repos
|
||||
/// </summary>
|
||||
[Parameter(Value = "Only")]
|
||||
[Parameter(Value = "only")]
|
||||
OnlyForks,
|
||||
/// <summary>
|
||||
/// include forked repos into the search
|
||||
/// </summary>
|
||||
[Parameter(Value = "True")]
|
||||
[Parameter(Value = "true")]
|
||||
IncludeForks
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user