From c89a29fa868bd389fe1f981742def3ef408c5701 Mon Sep 17 00:00:00 2001 From: Ryan Gribble Date: Sat, 11 Mar 2017 11:31:17 +1000 Subject: [PATCH 1/6] Update existing tests to use Octokit PR 1503 as it has some of the newer event types that are failing to deserialize --- .../Clients/IssueTimelineClientTests.cs | 19 +++++----------- .../ObservableIssueTimelineClientTests.cs | 22 +++++-------------- 2 files changed, 10 insertions(+), 31 deletions(-) diff --git a/Octokit.Tests.Integration/Clients/IssueTimelineClientTests.cs b/Octokit.Tests.Integration/Clients/IssueTimelineClientTests.cs index c19148f0..6ad9b6d5 100644 --- a/Octokit.Tests.Integration/Clients/IssueTimelineClientTests.cs +++ b/Octokit.Tests.Integration/Clients/IssueTimelineClientTests.cs @@ -26,24 +26,15 @@ namespace Octokit.Tests.Integration.Clients [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); @@ -54,7 +45,7 @@ namespace Octokit.Tests.Integration.Clients 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); } diff --git a/Octokit.Tests.Integration/Reactive/ObservableIssueTimelineClientTests.cs b/Octokit.Tests.Integration/Reactive/ObservableIssueTimelineClientTests.cs index 2608591b..ffad9fa5 100644 --- a/Octokit.Tests.Integration/Reactive/ObservableIssueTimelineClientTests.cs +++ b/Octokit.Tests.Integration/Reactive/ObservableIssueTimelineClientTests.cs @@ -24,28 +24,16 @@ namespace Octokit.Tests.Integration.Reactive [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); @@ -56,7 +44,7 @@ namespace Octokit.Tests.Integration.Reactive 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); From 7084a393960f24c3e50559c1935e6d5af7c49db0 Mon Sep 17 00:00:00 2001 From: Ryan Gribble Date: Sat, 11 Mar 2017 11:32:05 +1000 Subject: [PATCH 2/6] Write a timeline test that processes the most recent 20 closed PRs and 20 open Issues in octokit.net in attempt to more likely encounter a new EventType enum value added by github api changes --- .../Clients/IssueTimelineClientTests.cs | 36 +++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/Octokit.Tests.Integration/Clients/IssueTimelineClientTests.cs b/Octokit.Tests.Integration/Clients/IssueTimelineClientTests.cs index 6ad9b6d5..8f65c786 100644 --- a/Octokit.Tests.Integration/Clients/IssueTimelineClientTests.cs +++ b/Octokit.Tests.Integration/Clients/IssueTimelineClientTests.cs @@ -50,6 +50,42 @@ namespace Octokit.Tests.Integration.Clients Assert.Equal(1, timelineEventInfos.Count); } + [IntegrationTest] + public async Task CanRetrieveTimelineForRecentIssues() + { + // Make sure we can deserialize the event timeline for the 20 most recent closed PRs and 20 most recent open Issues from octokit.net + + // Search request + var github = Helper.GetAuthenticatedClient(); + var search = new SearchIssuesRequest + { + PerPage = 20, + Page = 1 + }; + search.Repos.Add("octokit", "octokit.net"); + + // 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("octokit", "octokit.net", 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("octokit", "octokit.net", issue.Number); + + Assert.NotNull(timelineEventInfos); + } + } + [IntegrationTest] public async Task CanDeserializeRenameEvent() { From 3a1e4b806fa0814c84d670dd255e64f8b508b76b Mon Sep 17 00:00:00 2001 From: Ryan Gribble Date: Sat, 11 Mar 2017 11:32:54 +1000 Subject: [PATCH 3/6] Fix failing tests by adding 2 new (undocumented) EventInfoState values --- Octokit/Models/Response/EventInfo.cs | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/Octokit/Models/Response/EventInfo.cs b/Octokit/Models/Response/EventInfo.cs index 34239a7c..b57c11e0 100644 --- a/Octokit/Models/Response/EventInfo.cs +++ b/Octokit/Models/Response/EventInfo.cs @@ -204,6 +204,17 @@ namespace Octokit /// url of the reference's source. /// [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Crossreferenced")] - Crossreferenced + Crossreferenced, + + /// + /// The issue was reveiewed. + /// + Reviewed, + + /// + /// A line comment was made. + /// + [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Linecommented")] + Linecommented } } From 3c8e5c60f0167bd384758d811dde28c9b64c51c4 Mon Sep 17 00:00:00 2001 From: Ryan Gribble Date: Sat, 11 Mar 2017 11:56:15 +1000 Subject: [PATCH 4/6] Changed test to use microsoft/vscode --- .../Clients/IssueTimelineClientTests.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Octokit.Tests.Integration/Clients/IssueTimelineClientTests.cs b/Octokit.Tests.Integration/Clients/IssueTimelineClientTests.cs index 8f65c786..355dd951 100644 --- a/Octokit.Tests.Integration/Clients/IssueTimelineClientTests.cs +++ b/Octokit.Tests.Integration/Clients/IssueTimelineClientTests.cs @@ -53,7 +53,7 @@ namespace Octokit.Tests.Integration.Clients [IntegrationTest] public async Task CanRetrieveTimelineForRecentIssues() { - // Make sure we can deserialize the event timeline for the 20 most recent closed PRs and 20 most recent open Issues from octokit.net + // 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(); @@ -62,7 +62,7 @@ namespace Octokit.Tests.Integration.Clients PerPage = 20, Page = 1 }; - search.Repos.Add("octokit", "octokit.net"); + search.Repos.Add("microsoft", "vscode"); // 20 most recent closed PRs search.Type = IssueTypeQualifier.PullRequest; @@ -70,7 +70,7 @@ namespace Octokit.Tests.Integration.Clients var pullRequestResults = await github.Search.SearchIssues(search); foreach (var pullRequest in pullRequestResults.Items) { - var timelineEventInfos = await _issueTimelineClient.GetAllForIssue("octokit", "octokit.net", pullRequest.Number); + var timelineEventInfos = await _issueTimelineClient.GetAllForIssue("microsoft", "vscode", pullRequest.Number); Assert.NotEmpty(timelineEventInfos); } @@ -80,7 +80,7 @@ namespace Octokit.Tests.Integration.Clients var issueResults = await github.Search.SearchIssues(search); foreach (var issue in issueResults.Items) { - var timelineEventInfos = await _issueTimelineClient.GetAllForIssue("octokit", "octokit.net", issue.Number); + var timelineEventInfos = await _issueTimelineClient.GetAllForIssue("microsoft", "vscode", issue.Number); Assert.NotNull(timelineEventInfos); } From 31bfc5c730469999977b4c6675e381a8d1843f46 Mon Sep 17 00:00:00 2001 From: Ryan Gribble Date: Sat, 11 Mar 2017 11:57:59 +1000 Subject: [PATCH 5/6] Found another new event type! --- Octokit/Models/Response/EventInfo.cs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/Octokit/Models/Response/EventInfo.cs b/Octokit/Models/Response/EventInfo.cs index b57c11e0..b15f1c2a 100644 --- a/Octokit/Models/Response/EventInfo.cs +++ b/Octokit/Models/Response/EventInfo.cs @@ -215,6 +215,12 @@ namespace Octokit /// A line comment was made. /// [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Linecommented")] - Linecommented + Linecommented, + + /// + /// A commit comment was made. + /// + [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Commitcommented")] + Commitcommented } } From a936184cff860c36e8d4a27507b64cb9fba2c70c Mon Sep 17 00:00:00 2001 From: Ryan Gribble Date: Thu, 16 Mar 2017 06:42:54 +1000 Subject: [PATCH 6/6] response enums can be camelcase as underscores are removed in the deserializer --- .../Clients/IssueTimelineClientTests.cs | 2 +- Octokit/Models/Response/EventInfo.cs | 6 ++---- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/Octokit.Tests.Integration/Clients/IssueTimelineClientTests.cs b/Octokit.Tests.Integration/Clients/IssueTimelineClientTests.cs index 355dd951..f7576fcf 100644 --- a/Octokit.Tests.Integration/Clients/IssueTimelineClientTests.cs +++ b/Octokit.Tests.Integration/Clients/IssueTimelineClientTests.cs @@ -82,7 +82,7 @@ namespace Octokit.Tests.Integration.Clients { var timelineEventInfos = await _issueTimelineClient.GetAllForIssue("microsoft", "vscode", issue.Number); - Assert.NotNull(timelineEventInfos); + Assert.NotEmpty(timelineEventInfos); } } diff --git a/Octokit/Models/Response/EventInfo.cs b/Octokit/Models/Response/EventInfo.cs index b15f1c2a..cda75079 100644 --- a/Octokit/Models/Response/EventInfo.cs +++ b/Octokit/Models/Response/EventInfo.cs @@ -214,13 +214,11 @@ namespace Octokit /// /// A line comment was made. /// - [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Linecommented")] - Linecommented, + LineCommented, /// /// A commit comment was made. /// - [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Commitcommented")] - Commitcommented + CommitCommented } }