-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Implement additional SearchIssuesRequest
options
#1228
Merged
Merged
Changes from 9 commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
f93df69
Add missing options to SearchIssuesRequest
ryangribble ccd2698
Add tests for each search parameter
ryangribble 78c7735
Add integration tests (including unskipping SearchAll test that shoul…
ryangribble 6d83412
Fix impacted test
ryangribble a12e528
Rename NotLabels to ExcludeLabels
ryangribble 4930a69
For consistency, create a new IssueTypeQualifier.PullRequest option t…
ryangribble 9fe9df7
Fix impacted test
ryangribble 142ea7a
Move exclusions to a new class, tested against the API and implemente…
ryangribble 4c0fdfa
Fix missing XmlDoc tag
ryangribble a62e580
Use correct [IntegrationTest] attribute
ryangribble 3de5196
everyone's always hatin' on the Tuple :p
ryangribble 920bef8
Merge remote-tracking branch 'upstream/master' into search-issues
ryangribble bc5dc88
Dont use the field i just obsoleted :)
ryangribble File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
85 changes: 85 additions & 0 deletions
85
Octokit.Tests/Models/SearchIssuesRequestExclusionsTests.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using Octokit; | ||
using Octokit.Tests.Helpers; | ||
using Xunit; | ||
|
||
public class SearchIssuesRequestExclusionsTests | ||
{ | ||
public class TheExclusionsMergedQualifiersMethod | ||
{ | ||
[Fact] | ||
public void HandlesStringAttributesCorrectly() | ||
{ | ||
var stringProperties = new List<Tuple<string, Action<SearchIssuesRequestExclusions, string>>>() | ||
{ | ||
new Tuple<string, Action<SearchIssuesRequestExclusions, string>>("author:", (x,value) => x.Author = value), | ||
new Tuple<string, Action<SearchIssuesRequestExclusions, string>>("assignee:", (x,value) => x.Assignee = value), | ||
new Tuple<string, Action<SearchIssuesRequestExclusions, string>>("mentions:", (x,value) => x.Mentions = value), | ||
new Tuple<string, Action<SearchIssuesRequestExclusions, string>>("commenter:", (x,value) => x.Commenter = value), | ||
new Tuple<string, Action<SearchIssuesRequestExclusions, string>>("involves:", (x,value) => x.Involves = value), | ||
new Tuple<string, Action<SearchIssuesRequestExclusions, string>>("head:", (x,value) => x.Head = value), | ||
new Tuple<string, Action<SearchIssuesRequestExclusions, string>>("base:", (x,value) => x.Base = value) | ||
}; | ||
|
||
foreach (var property in stringProperties) | ||
{ | ||
var request = new SearchIssuesRequestExclusions(); | ||
|
||
// Ensure the specified parameter does not exist when not set | ||
Assert.False(request.MergedQualifiers().Any(x => x.Contains(property.Item1))); | ||
|
||
// Set the parameter | ||
property.Item2(request, "blah"); | ||
|
||
// Ensure the specified parameter now exists | ||
Assert.True(request.MergedQualifiers().Count(x => x.Contains(property.Item1)) == 1); | ||
} | ||
} | ||
|
||
[Fact] | ||
public void HandlesStateAttributeCorrectly() | ||
{ | ||
var request = new SearchIssuesRequestExclusions(); | ||
Assert.False(request.MergedQualifiers().Any(x => x.Contains("-state:"))); | ||
|
||
request.State = ItemState.Closed; | ||
Assert.True(request.MergedQualifiers().Contains("-state:closed")); | ||
} | ||
|
||
[Fact] | ||
public void HandlesExcludeLabelsAttributeCorrectly() | ||
{ | ||
var request = new SearchIssuesRequestExclusions(); | ||
Assert.False(request.MergedQualifiers().Any(x => x.Contains("-label:"))); | ||
|
||
request.Labels = new[] { "label1", "label2" }; | ||
|
||
Assert.True(request.MergedQualifiers().Contains("-label:label1")); | ||
Assert.True(request.MergedQualifiers().Contains("-label:label2")); | ||
} | ||
|
||
[Fact] | ||
public void HandlesLanguageAttributeCorrectly() | ||
{ | ||
var request = new SearchIssuesRequestExclusions(); | ||
Assert.False(request.MergedQualifiers().Any(x => x.Contains("-language:"))); | ||
|
||
request.Language = Language.CSharp; | ||
|
||
Assert.True(request.MergedQualifiers().Contains("-language:C#")); | ||
} | ||
|
||
[Fact] | ||
public void HandlesStatusAttributeCorrectly() | ||
{ | ||
var request = new SearchIssuesRequestExclusions(); | ||
Assert.False(request.MergedQualifiers().Any(x => x.Contains("-status:"))); | ||
|
||
request.Status = CommitState.Error; | ||
|
||
Assert.True(request.MergedQualifiers().Contains("-status:error")); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Semantics, but perhaps
Dictionary<string,Action<SearchIssuesRequest, DateRange>>
instead of crafting tuples?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Poor old Tuples everyone hates them! Yep good idea not sure how I ended up with
<List<Tuple<
instead of just aDictionary<
hahah 😀These are now tidied up