Skip to content

Commit

Permalink
add islocked filter to SeachIssuesRequest (#2623)
Browse files Browse the repository at this point in the history
* add islocker filter to SeachIssuesRequest

* update docs

* Update docs/search.md with review suggestions

Co-authored-by: Keegan Campbell <[email protected]>

Co-authored-by: notauserx <[email protected]>
Co-authored-by: Keegan Campbell <[email protected]>
  • Loading branch information
3 people authored Nov 30, 2022
1 parent 6c11c1e commit 46b5077
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 1 deletion.
22 changes: 22 additions & 0 deletions Octokit.Tests.Integration/Clients/SearchClientTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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> { 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> { 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()
{
Expand Down
11 changes: 11 additions & 0 deletions Octokit.Tests/Models/SearchIssuesRequestTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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> { IssueIsQualifier.Locked, IssueIsQualifier.Unlocked };
Assert.Contains("is:locked", request.MergedQualifiers());
Assert.Contains("is:unlocked", request.MergedQualifiers());
}

[Fact]
public void HandlesStatusAttributeCorrectly()
{
Expand Down
6 changes: 5 additions & 1 deletion Octokit/Models/Request/SearchIssuesRequest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 8 additions & 0 deletions docs/search.md
Original file line number Diff line number Diff line change
Expand Up @@ -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> {
IssueIsQualifier.Issue,
IssueIsQualifier.Locked
};
```

There's other options available to control how the results are returned:
Expand Down

0 comments on commit 46b5077

Please sign in to comment.