Skip to content

Commit

Permalink
Add integration tests (including unskipping SearchAll test that shoul…
Browse files Browse the repository at this point in the history
…d work now)

Fixup doc comments
  • Loading branch information
ryangribble committed Mar 29, 2016
1 parent 66055c3 commit a0bf0ba
Show file tree
Hide file tree
Showing 3 changed files with 74 additions and 6 deletions.
62 changes: 60 additions & 2 deletions Octokit.Tests.Integration/Clients/SearchClientTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand All @@ -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");
Expand Down Expand Up @@ -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> { 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<string> { "up-for-grabs" };

var notLabelRequest = new SearchIssuesRequest();
notLabelRequest.Repos.Add("octokit", "octokit.net");
notLabelRequest.NotLabels = new List<string> { "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);
}
}
2 changes: 1 addition & 1 deletion Octokit.Tests/Models/SearchIssuesRequestTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
16 changes: 13 additions & 3 deletions Octokit/Models/Request/SearchIssuesRequest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

/// <summary>
/// Optional Sort field. One of comments, created, updated or merged
/// If not provided, results are sorted by best match.
Expand Down Expand Up @@ -182,13 +192,13 @@ public IEnumerable<string> NotLabels
/// Searches for issues within repositories that match a certain language.
/// </summary>
/// <remarks>
/// 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
/// </remarks>
public Language? Language { get; set; }

private IEnumerable<IssueIsQualifier> _is;
/// <summary>
/// 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
/// </summary>
/// <remarks>
/// https://help.github.com/articles/searching-issues/#search-based-on-the-state-of-an-issue-or-pull-request
Expand Down Expand Up @@ -349,7 +359,7 @@ public override IReadOnlyList<string> 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)
Expand Down

0 comments on commit a0bf0ba

Please sign in to comment.