diff --git a/Octokit.Tests.Integration/Clients/SearchClientTests.cs b/Octokit.Tests.Integration/Clients/SearchClientTests.cs index c64d6a02f2..9123ecdc3c 100644 --- a/Octokit.Tests.Integration/Clients/SearchClientTests.cs +++ b/Octokit.Tests.Integration/Clients/SearchClientTests.cs @@ -281,6 +281,28 @@ public async Task SearchForAllIssuesUsingTerm() Assert.NotEmpty(openedIssues); } + [IntegrationTest] + public async Task SearchForLockedUnlockedIssues() + { + + var lockedIssuesRequest = new SearchIssuesRequest(); + lockedIssuesRequest.Repos.Add("octokit", "octokit.net"); + lockedIssuesRequest.Is = new List { IssueIsQualifier.Issue, IssueIsQualifier.Locked }; + + var lockedIssues = await _gitHubClient.Search.SearchIssues(lockedIssuesRequest); + + var unlockedIssuesRequest = new SearchIssuesRequest(); + + unlockedIssuesRequest.Repos.Add("octokit", "octokit.net"); + unlockedIssuesRequest.Is = new List { IssueIsQualifier.Issue, IssueIsQualifier.Unlocked }; + + + var unlockedIssues = await _gitHubClient.Search.SearchIssues(unlockedIssuesRequest); + + Assert.All(lockedIssues.Items, i => Assert.True(i.Locked)); + Assert.All(unlockedIssues.Items, i => Assert.False(i.Locked)); + } + [IntegrationTest] public async Task SearchForMergedPullRequests() { diff --git a/Octokit.Tests/Models/SearchIssuesRequestTests.cs b/Octokit.Tests/Models/SearchIssuesRequestTests.cs index 9227e7a8e0..dfa5e55a69 100644 --- a/Octokit.Tests/Models/SearchIssuesRequestTests.cs +++ b/Octokit.Tests/Models/SearchIssuesRequestTests.cs @@ -170,6 +170,17 @@ public void HandlesIsAttributeCorrectly() Assert.Contains("is:pr", request.MergedQualifiers()); } + [Fact] + public void HandlesIsLockedUnlockedAttributeCorrectly() + { + var request = new SearchIssuesRequest("test"); + Assert.DoesNotContain(request.MergedQualifiers(), x => x.Contains("is:")); + + request.Is = new List { IssueIsQualifier.Locked, IssueIsQualifier.Unlocked }; + Assert.Contains("is:locked", request.MergedQualifiers()); + Assert.Contains("is:unlocked", request.MergedQualifiers()); + } + [Fact] public void HandlesStatusAttributeCorrectly() { diff --git a/Octokit/Models/Request/SearchIssuesRequest.cs b/Octokit/Models/Request/SearchIssuesRequest.cs index acb33c6f47..391e04130a 100644 --- a/Octokit/Models/Request/SearchIssuesRequest.cs +++ b/Octokit/Models/Request/SearchIssuesRequest.cs @@ -489,7 +489,11 @@ public enum IssueIsQualifier [Parameter(Value = "private")] Private, [Parameter(Value = "public")] - Public + Public, + [Parameter(Value = "locked")] + Locked, + [Parameter(Value = "unlocked")] + Unlocked } public enum IssueNoMetadataQualifier diff --git a/docs/search.md b/docs/search.md index 1c3e1c7f90..95dfdc218b 100644 --- a/docs/search.md +++ b/docs/search.md @@ -61,6 +61,14 @@ request.Involves = "terrajobst"; request.State = ItemState.All; // or to just search closed issues request.State = ItemState.Closed; + +// you can filter by the "Is" qualifier +// the enum IssueIsQualifier contains the supported values +// you can filter for locked issues like this: +request.Is = new List { + IssueIsQualifier.Issue, + IssueIsQualifier.Locked +}; ``` There's other options available to control how the results are returned: