Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add islocked filter to SeachIssuesRequest #2623

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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