diff --git a/Octokit.Tests.Integration/Clients/SearchClientTests.cs b/Octokit.Tests.Integration/Clients/SearchClientTests.cs index 3292c39090..95b70213ce 100644 --- a/Octokit.Tests.Integration/Clients/SearchClientTests.cs +++ b/Octokit.Tests.Integration/Clients/SearchClientTests.cs @@ -86,7 +86,7 @@ public async Task SearchForOpenIssues() Assert.NotEmpty(issues.Items); } - [Fact(Skip = "see https://github.com/octokit/octokit.net/issues/1082 for investigating this failing test")] + [Fact] public async Task SearchForAllIssues() { var request = new SearchIssuesRequest("phone"); @@ -98,7 +98,7 @@ public async Task SearchForAllIssues() } [Fact] - public async Task SearchForAllIssuesWithouTaskUsingTerm() + public async Task SearchForAllIssuesWithoutUsingTerm() { var request = new SearchIssuesRequest(); request.Repos.Add("caliburn-micro/caliburn.micro"); @@ -126,4 +126,62 @@ public async Task SearchForAllIssuesUsingTerm() Assert.NotEmpty(closedIssues); Assert.NotEmpty(openedIssues); } + + [Fact] + public async Task SearchForMergedPullRequests() + { + var allRequest = new SearchIssuesRequest(); + allRequest.Repos.Add("octokit", "octokit.net"); + allRequest.Type = IssueTypeQualifier.PR; + + var mergedRequest = new SearchIssuesRequest(); + mergedRequest.Repos.Add("octokit", "octokit.net"); + mergedRequest.Is = new List { IssueIsQualifier.PullRequest, IssueIsQualifier.Merged }; + + var allPullRequests = await _gitHubClient.Search.SearchIssues(allRequest); + var mergedPullRequests = await _gitHubClient.Search.SearchIssues(mergedRequest); + + Assert.NotEmpty(allPullRequests.Items); + Assert.NotEmpty(mergedPullRequests.Items); + Assert.NotEqual(allPullRequests.TotalCount, mergedPullRequests.TotalCount); + } + + [Fact] + public async Task SearchForLabelsAndExcludedLabels() + { + var labelRequest = new SearchIssuesRequest(); + labelRequest.Repos.Add("octokit", "octokit.net"); + labelRequest.Labels = new List { "up-for-grabs" }; + + var notLabelRequest = new SearchIssuesRequest(); + notLabelRequest.Repos.Add("octokit", "octokit.net"); + notLabelRequest.NotLabels = new List { "up-for-grabs" }; + + var upForGrabs = await _gitHubClient.Search.SearchIssues(labelRequest); + var notUpForGrabs = await _gitHubClient.Search.SearchIssues(notLabelRequest); + + Assert.NotEmpty(upForGrabs.Items); + Assert.NotEmpty(notUpForGrabs.Items); + Assert.NotEqual(upForGrabs.TotalCount, notUpForGrabs.TotalCount); + + Assert.False(upForGrabs.Items.Any(x1 => notUpForGrabs.Items.Any(x2 => x2.Number == x1.Number))); + } + + [Fact] + public async Task SearchForMissingMetadata() + { + var allRequest = new SearchIssuesRequest(); + allRequest.Repos.Add("octokit", "octokit.net"); + + var noAssigneeRequest = new SearchIssuesRequest(); + noAssigneeRequest.Repos.Add("octokit", "octokit.net"); + noAssigneeRequest.No = IssueNoMetadataQualifier.Assignee; + + var allIssues = await _gitHubClient.Search.SearchIssues(allRequest); + var noAssigneeIssues = await _gitHubClient.Search.SearchIssues(noAssigneeRequest); + + Assert.NotEmpty(allIssues.Items); + Assert.NotEmpty(noAssigneeIssues.Items); + Assert.NotEqual(allIssues.TotalCount, noAssigneeIssues.TotalCount); + } } diff --git a/Octokit.Tests/Models/SearchIssuesRequestTests.cs b/Octokit.Tests/Models/SearchIssuesRequestTests.cs index 0323d938fb..4371859ebc 100644 --- a/Octokit.Tests/Models/SearchIssuesRequestTests.cs +++ b/Octokit.Tests/Models/SearchIssuesRequestTests.cs @@ -144,7 +144,7 @@ public void HandlesLanguageAttributeCorrectly() Assert.False(request.MergedQualifiers().Any(x => x.Contains("language:"))); request.Language = Language.CSharp; - Assert.True(request.MergedQualifiers().Contains("language:CSharp")); + Assert.True(request.MergedQualifiers().Contains("language:C#")); } [Fact] diff --git a/Octokit/Models/Request/SearchIssuesRequest.cs b/Octokit/Models/Request/SearchIssuesRequest.cs index caebeec69f..b5307d8848 100644 --- a/Octokit/Models/Request/SearchIssuesRequest.cs +++ b/Octokit/Models/Request/SearchIssuesRequest.cs @@ -32,6 +32,16 @@ public SearchIssuesRequest(string term) : base(term) Repos = new RepositoryCollection(); } + [Obsolete("this will be deprecated in a future version")] + public SearchIssuesRequest(string term, string owner, string name) + : this(term) + { + Ensure.ArgumentNotNullOrEmptyString(owner, "owner"); + Ensure.ArgumentNotNullOrEmptyString(name, "name"); + + Repos.Add(owner, name); + } + /// /// Optional Sort field. One of comments, created, updated or merged /// If not provided, results are sorted by best match. @@ -182,13 +192,13 @@ public IEnumerable NotLabels /// Searches for issues within repositories that match a certain language. /// /// - /// https://help.github.com/articles/searching-issues/#search-by-the-labels-on-an-issue + /// https://help.github.com/articles/searching-issues/#search-by-the-main-language-of-a-repository /// public Language? Language { get; set; } private IEnumerable _is; /// - /// Searches for issues using a more human syntax covering options like state, type and merged status + /// Searches for issues using a more human syntax covering options like state, type, merged status, private/public repository /// /// /// https://help.github.com/articles/searching-issues/#search-based-on-the-state-of-an-issue-or-pull-request @@ -349,7 +359,7 @@ public override IReadOnlyList MergedQualifiers() if (Language != null) { - parameters.Add(string.Format(CultureInfo.InvariantCulture, "language:{0}", Language)); + parameters.Add(string.Format(CultureInfo.InvariantCulture, "language:{0}", Language.ToParameter())); } if (Is != null)