From 6e9588d49011dfed803bf74781a89664714748fb Mon Sep 17 00:00:00 2001 From: "aedampir@gmail.com" Date: Mon, 6 Jun 2016 17:52:30 +0700 Subject: [PATCH] added integration tests --- .../Clients/RepositoryCommitsClientTests.cs | 200 ++++++++++++++++++ 1 file changed, 200 insertions(+) diff --git a/Octokit.Tests.Integration/Clients/RepositoryCommitsClientTests.cs b/Octokit.Tests.Integration/Clients/RepositoryCommitsClientTests.cs index d6f61a20..9197792f 100644 --- a/Octokit.Tests.Integration/Clients/RepositoryCommitsClientTests.cs +++ b/Octokit.Tests.Integration/Clients/RepositoryCommitsClientTests.cs @@ -27,6 +27,13 @@ public class RepositoryCommitsClientTests Assert.NotNull(compareResult.MergeBaseCommit); } + [IntegrationTest] + public async Task CanGetMergeBaseCommitByRepositoryId() + { + var compareResult = await _fixture.Compare(7528679, "65a22f4d2cff94a286ac3e96440c810c5509196f", "65a22f4d2cff94a286ac3e96440c810c5509196f"); + Assert.NotNull(compareResult.MergeBaseCommit); + } + [IntegrationTest] public async Task CanGetCommit() { @@ -34,6 +41,13 @@ public class RepositoryCommitsClientTests Assert.NotNull(commit); } + [IntegrationTest] + public async Task CanGetCommitByRepositoryId() + { + var commit = await _fixture.Get(7528679, "65a22f4d2cff94a286ac3e96440c810c5509196f"); + Assert.NotNull(commit); + } + [IntegrationTest] public async Task CanGetCommitWithFiles() { @@ -42,6 +56,14 @@ public class RepositoryCommitsClientTests Assert.True(commit.Files.Any(file => file.Filename.EndsWith("IConnection.cs"))); } + [IntegrationTest] + public async Task CanGetCommitWithFilesByRepositoryId() + { + var commit = await _fixture.Get(7528679, "65a22f4d2cff94a286ac3e96440c810c5509196f"); + + Assert.True(commit.Files.Any(file => file.Filename.EndsWith("IConnection.cs"))); + } + [IntegrationTest] public async Task CanGetListOfCommits() { @@ -49,6 +71,13 @@ public class RepositoryCommitsClientTests Assert.NotEmpty(list); } + [IntegrationTest] + public async Task CanGetListOfCommitsByRepositoryId() + { + var list = await _fixture.GetAll(22718025); + Assert.NotEmpty(list); + } + [IntegrationTest] public async Task CanGetCorrectCountOfCommitsWithoutStart() { @@ -62,6 +91,19 @@ public class RepositoryCommitsClientTests Assert.Equal(5, commits.Count); } + [IntegrationTest] + public async Task CanGetCorrectCountOfCommitsWithoutStartByRepositoryId() + { + var options = new ApiOptions + { + PageSize = 5, + PageCount = 1 + }; + + var commits = await _fixture.GetAll(22718025, options); + Assert.Equal(5, commits.Count); + } + [IntegrationTest] public async Task CanGetCorrectCountOfCommitsWithStart() { @@ -76,6 +118,20 @@ public class RepositoryCommitsClientTests Assert.Equal(5, commits.Count); } + [IntegrationTest] + public async Task CanGetCorrectCountOfCommitsWithStartByRepositoryId() + { + var options = new ApiOptions + { + PageSize = 5, + PageCount = 1, + StartPage = 2 + }; + + var commits = await _fixture.GetAll(22718025, options); + Assert.Equal(5, commits.Count); + } + [IntegrationTest] public async Task ReturnsDistinctResultsBasedOnStart() { @@ -102,6 +158,32 @@ public class RepositoryCommitsClientTests Assert.NotEqual(firstCommit[4].Sha, secondCommit[4].Sha); } + [IntegrationTest] + public async Task ReturnsDistinctResultsBasedOnStartByRepositoryId() + { + var startOptions = new ApiOptions + { + PageSize = 5, + PageCount = 1 + }; + + var skipStartOptions = new ApiOptions + { + PageSize = 5, + PageCount = 1, + StartPage = 2 + }; + + var firstCommit = await _fixture.GetAll(22718025, startOptions); + var secondCommit = await _fixture.GetAll(22718025, skipStartOptions); + + Assert.NotEqual(firstCommit[0].Sha, secondCommit[0].Sha); + Assert.NotEqual(firstCommit[1].Sha, secondCommit[1].Sha); + Assert.NotEqual(firstCommit[2].Sha, secondCommit[2].Sha); + Assert.NotEqual(firstCommit[3].Sha, secondCommit[3].Sha); + Assert.NotEqual(firstCommit[4].Sha, secondCommit[4].Sha); + } + [IntegrationTest] public async Task CanGetListOfCommitsBySha() { @@ -110,6 +192,14 @@ public class RepositoryCommitsClientTests Assert.NotEmpty(list); } + [IntegrationTest] + public async Task CanGetListOfCommitsByShaByRepositoryId() + { + var request = new CommitRequest { Sha = "08b363d45d6ae8567b75dfa45c032a288584afd4" }; + var list = await _fixture.GetAll(7528679, request); + Assert.NotEmpty(list); + } + [IntegrationTest] public async Task CanGetListOfCommitsByPath() { @@ -118,6 +208,14 @@ public class RepositoryCommitsClientTests Assert.NotEmpty(list); } + [IntegrationTest] + public async Task CanGetListOfCommitsByPathByRepositoryId() + { + var request = new CommitRequest { Path = "Octokit.Reactive/IObservableGitHubClient.cs" }; + var list = await _fixture.GetAll(7528679, request); + Assert.NotEmpty(list); + } + [IntegrationTest] public async Task CanGetListOfCommitsByAuthor() { @@ -126,6 +224,14 @@ public class RepositoryCommitsClientTests Assert.NotEmpty(list); } + [IntegrationTest] + public async Task CanGetListOfCommitsByAuthorByRepositoryId() + { + var request = new CommitRequest { Author = "kzu" }; + var list = await _fixture.GetAll(7528679, request); + Assert.NotEmpty(list); + } + [IntegrationTest] public async Task CanGetListOfCommitsByDateRange() { @@ -138,6 +244,18 @@ public class RepositoryCommitsClientTests Assert.NotEmpty(list); } + [IntegrationTest] + public async Task CanGetListOfCommitsByDateRangeByRepositoryId() + { + var offset = new TimeSpan(1, 0, 0); + var since = new DateTimeOffset(2014, 1, 1, 0, 0, 0, offset); + var until = new DateTimeOffset(2014, 1, 8, 0, 0, 0, offset); + + var request = new CommitRequest { Since = since, Until = until }; + var list = await _fixture.GetAll(7528679, request); + Assert.NotEmpty(list); + } + [IntegrationTest] public async Task CanGetCommitWithRenamedFiles() { @@ -148,6 +266,16 @@ public class RepositoryCommitsClientTests .All(file => string.IsNullOrEmpty(file.PreviousFileName) == false)); } + [IntegrationTest] + public async Task CanGetCommitWithRenamedFilesByRepositoryId() + { + var commit = await _fixture.Get(7528679, "997e955f38eb0c2c36e55b1588455fa857951dbf"); + + Assert.True(commit.Files + .Where(file => file.Status == "renamed") + .All(file => string.IsNullOrEmpty(file.PreviousFileName) == false)); + } + [IntegrationTest] public async Task CanGetSha1() { @@ -155,6 +283,14 @@ public class RepositoryCommitsClientTests Assert.NotNull(sha1); } + + [IntegrationTest] + public async Task CanGetSha1ByRepositoryId() + { + var sha1 = await _fixture.GetSha1(7528679, "master"); + + Assert.NotNull(sha1); + } } public class TestsWithNewRepository : IDisposable @@ -185,6 +321,19 @@ public class RepositoryCommitsClientTests Assert.Equal(0, result.BehindBy); } + [IntegrationTest] + public async Task CanCompareReferencesByRepositoryId() + { + await CreateTheWorld(); + + var result = await _fixture.Compare(_context.Repository.Id, "master", "my-branch"); + + Assert.Equal(1, result.TotalCommits); + Assert.Equal(1, result.Commits.Count); + Assert.Equal(1, result.AheadBy); + Assert.Equal(0, result.BehindBy); + } + [IntegrationTest] public async Task CanCompareReferencesOtherWayRound() { @@ -198,6 +347,19 @@ public class RepositoryCommitsClientTests Assert.Equal(1, result.BehindBy); } + [IntegrationTest] + public async Task CanCompareReferencesOtherWayRoundByRepositoryId() + { + await CreateTheWorld(); + + var result = await _fixture.Compare(_context.Repository.Id, "my-branch", "master"); + + Assert.Equal(0, result.TotalCommits); + Assert.Equal(0, result.Commits.Count); + Assert.Equal(0, result.AheadBy); + Assert.Equal(1, result.BehindBy); + } + [IntegrationTest] public async Task ReturnsUrlsToResources() { @@ -211,6 +373,19 @@ public class RepositoryCommitsClientTests Assert.NotNull(result.PermalinkUrl); } + [IntegrationTest] + public async Task ReturnsUrlsToResourcesByRepositoryId() + { + await CreateTheWorld(); + + var result = await _fixture.Compare(_context.Repository.Id, "my-branch", "master"); + + Assert.NotNull(result.DiffUrl); + Assert.NotNull(result.HtmlUrl); + Assert.NotNull(result.PatchUrl); + Assert.NotNull(result.PermalinkUrl); + } + [IntegrationTest] public async Task CanCompareUsingSha() { @@ -226,6 +401,21 @@ public class RepositoryCommitsClientTests Assert.Equal(0, result.BehindBy); } + [IntegrationTest] + public async Task CanCompareUsingShaByRepositoryId() + { + await CreateTheWorld(); + + var master = await _github.Git.Reference.Get(Helper.UserName, _context.RepositoryName, "heads/master"); + var branch = await _github.Git.Reference.Get(Helper.UserName, _context.RepositoryName, "heads/my-branch"); + + var result = await _fixture.Compare(_context.Repository.Id, master.Object.Sha, branch.Object.Sha); + + Assert.Equal(1, result.Commits.Count); + Assert.Equal(1, result.AheadBy); + Assert.Equal(0, result.BehindBy); + } + [IntegrationTest] public async Task GetSha1FromRepository() { @@ -236,6 +426,16 @@ public class RepositoryCommitsClientTests Assert.Equal(reference.Object.Sha, sha1); } + [IntegrationTest] + public async Task GetSha1FromRepositoryByRepositoryId() + { + var reference = await CreateTheWorld(); + + var sha1 = await _fixture.GetSha1(_context.Repository.Id, "my-branch"); + + Assert.Equal(reference.Object.Sha, sha1); + } + async Task CreateTheWorld() { var master = await _github.Git.Reference.Get(Helper.UserName, _context.RepositoryName, "heads/master");