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

Fix Issue Timeline exceptions by adding new EventInfoState values #1563

Merged
merged 6 commits into from
Apr 2, 2017
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
55 changes: 41 additions & 14 deletions Octokit.Tests.Integration/Clients/IssueTimelineClientTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,24 +26,15 @@ public IssueTimelineClientTests()
[IntegrationTest]
public async Task CanRetrieveTimelineForIssue()
{
var newIssue = new NewIssue("a test issue") { Body = "A new unassigned issue" };
var issue = await _issuesClient.Create(_context.RepositoryOwner, _context.RepositoryName, newIssue);

var timelineEventInfos = await _issueTimelineClient.GetAllForIssue(_context.RepositoryOwner, _context.RepositoryName, issue.Number);
Assert.Empty(timelineEventInfos);

var closed = await _issuesClient.Update(_context.RepositoryOwner, _context.RepositoryName, issue.Number, new IssueUpdate() { State = ItemState.Closed });
Assert.NotNull(closed);

timelineEventInfos = await _issueTimelineClient.GetAllForIssue(_context.RepositoryOwner, _context.RepositoryName, issue.Number);
Assert.Equal(1, timelineEventInfos.Count);
Assert.Equal(EventInfoState.Closed, timelineEventInfos[0].Event);
var timelineEventInfos = await _issueTimelineClient.GetAllForIssue("octokit", "octokit.net", 1503);
Assert.NotEmpty(timelineEventInfos);
Assert.NotEqual(0, timelineEventInfos.Count);
}

[IntegrationTest]
public async Task CanRetrieveTimelineForIssueWithApiOptions()
{
var timelineEventInfos = await _issueTimelineClient.GetAllForIssue("octokit", "octokit.net", 1115);
var timelineEventInfos = await _issueTimelineClient.GetAllForIssue("octokit", "octokit.net", 1503);
Assert.NotEmpty(timelineEventInfos);
Assert.NotEqual(1, timelineEventInfos.Count);

Expand All @@ -54,11 +45,47 @@ public async Task CanRetrieveTimelineForIssueWithApiOptions()
StartPage = 1
};

timelineEventInfos = await _issueTimelineClient.GetAllForIssue("octokit", "octokit.net", 1115, pageOptions);
timelineEventInfos = await _issueTimelineClient.GetAllForIssue("octokit", "octokit.net", 1503, pageOptions);
Assert.NotEmpty(timelineEventInfos);
Assert.Equal(1, timelineEventInfos.Count);
}

[IntegrationTest]
public async Task CanRetrieveTimelineForRecentIssues()
{
// Make sure we can deserialize the event timeline for recent closed PRs and open Issues in a heavy activity repository (microsoft/vscode)

// Search request
var github = Helper.GetAuthenticatedClient();
var search = new SearchIssuesRequest
{
PerPage = 20,
Page = 1
};
search.Repos.Add("microsoft", "vscode");

// 20 most recent closed PRs
search.Type = IssueTypeQualifier.PullRequest;
search.State = ItemState.Closed;
var pullRequestResults = await github.Search.SearchIssues(search);
foreach (var pullRequest in pullRequestResults.Items)
{
var timelineEventInfos = await _issueTimelineClient.GetAllForIssue("microsoft", "vscode", pullRequest.Number);
Assert.NotEmpty(timelineEventInfos);
}

// 20 most recent open Issues
search.Type = IssueTypeQualifier.Issue;
search.State = ItemState.Open;
var issueResults = await github.Search.SearchIssues(search);
foreach (var issue in issueResults.Items)
{
var timelineEventInfos = await _issueTimelineClient.GetAllForIssue("microsoft", "vscode", issue.Number);

Assert.NotEmpty(timelineEventInfos);
}
}

[IntegrationTest]
public async Task CanDeserializeRenameEvent()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,28 +24,16 @@ public ObservableIssueTimelineClientTests()
[IntegrationTest]
public async Task CanRetrieveTimelineForIssue()
{
var newIssue = new NewIssue("a test issue") { Body = "A new unassigned issue" };
var observable = _client.Issue.Create(_context.Repository.Id, newIssue);
var issue = await observable;

var observableTimeline = _client.Issue.Timeline.GetAllForIssue(_context.RepositoryOwner, _context.RepositoryName, issue.Number);
var observableTimeline = _client.Issue.Timeline.GetAllForIssue("octokit", "octokit.net", 1503);
var timelineEventInfos = await observableTimeline.ToList();
Assert.Empty(timelineEventInfos);

observable = _client.Issue.Update(_context.Repository.Id, issue.Number, new IssueUpdate { State = ItemState.Closed });
var closed = await observable;
Assert.NotNull(closed);

observableTimeline = _client.Issue.Timeline.GetAllForIssue(_context.RepositoryOwner, _context.RepositoryName, issue.Number);
timelineEventInfos = await observableTimeline.ToList();
Assert.Equal(1, timelineEventInfos.Count);
Assert.Equal(EventInfoState.Closed, timelineEventInfos[0].Event);
Assert.NotEmpty(timelineEventInfos);
Assert.NotEqual(0, timelineEventInfos.Count);
}

[IntegrationTest]
public async Task CanRetrieveTimelineForIssueWithApiOptions()
{
var observableTimeline = _client.Issue.Timeline.GetAllForIssue("octokit", "octokit.net", 1115);
var observableTimeline = _client.Issue.Timeline.GetAllForIssue("octokit", "octokit.net", 1503);
var timelineEventInfos = await observableTimeline.ToList();
Assert.NotEmpty(timelineEventInfos);
Assert.NotEqual(1, timelineEventInfos.Count);
Expand All @@ -56,7 +44,7 @@ public async Task CanRetrieveTimelineForIssueWithApiOptions()
PageCount = 1,
StartPage = 1
};
observableTimeline = _client.Issue.Timeline.GetAllForIssue("octokit", "octokit.net", 1115, pageOptions);
observableTimeline = _client.Issue.Timeline.GetAllForIssue("octokit", "octokit.net", 1503, pageOptions);
timelineEventInfos = await observableTimeline.ToList();
Assert.NotEmpty(timelineEventInfos);
Assert.Equal(1, timelineEventInfos.Count);
Expand Down
17 changes: 16 additions & 1 deletion Octokit/Models/Response/EventInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,21 @@ public enum EventInfoState
/// url of the reference's source.
/// </summary>
[SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Crossreferenced")]
Crossreferenced
Crossreferenced,

/// <summary>
/// The issue was reveiewed.
/// </summary>
Reviewed,

/// <summary>
/// A line comment was made.
/// </summary>
LineCommented,

/// <summary>
/// A commit comment was made.
/// </summary>
CommitCommented
}
}