From c41c4b6117918f852405b2cc2e217efa2a9477f1 Mon Sep 17 00:00:00 2001 From: Kristian Hald Date: Sat, 14 Mar 2015 16:43:24 +0100 Subject: [PATCH] The integration tests for the 'Forks' github api matching the current implementation of the forks api. --- .../Clients/RepositoryForksClientTests.cs | 62 +++++++++++++++++++ .../Octokit.Tests.Integration.csproj | 1 + 2 files changed, 63 insertions(+) create mode 100644 Octokit.Tests.Integration/Clients/RepositoryForksClientTests.cs diff --git a/Octokit.Tests.Integration/Clients/RepositoryForksClientTests.cs b/Octokit.Tests.Integration/Clients/RepositoryForksClientTests.cs new file mode 100644 index 00000000..621180b6 --- /dev/null +++ b/Octokit.Tests.Integration/Clients/RepositoryForksClientTests.cs @@ -0,0 +1,62 @@ +using System; +using System.Linq; +using System.Threading.Tasks; +using Xunit; + +namespace Octokit.Tests.Integration.Clients +{ + public class RepositoryForksClientTests + { + public class TheGetMethod + { + [IntegrationTest] + public async Task ReturnsForksForProject() + { + var github = Helper.GetAuthenticatedClient(); + + var forks = await github.Repository.Forks.Get("octokit", "octokit.net"); + + var masterFork = forks.FirstOrDefault(fork => fork.FullName == "TeamBinary/octokit.net"); + Assert.NotNull(masterFork); + Assert.Equal("TeamBinary", masterFork.Owner.Login); + } + } + + public class TheCreateMethod + { + [IntegrationTest] + public async Task ForkCreatedForUserLoggedIn() + { + // The fork is created asynchronially by github and therefore it cannot + // be certain that the repo exists when the test ends. It is therefore deleted + // before the test starts instead of after. + Helper.DeleteRepo(Helper.Credentials.Login, "octokit.net"); + + var github = Helper.GetAuthenticatedClient(); + + var forkCreated = await github.Repository.Forks.Create("octokit", "octokit.net", new NewRepositoryFork()); + + Assert.NotNull(forkCreated); + Assert.Equal(String.Format("{0}/octokit.net", Helper.Credentials.Login), forkCreated.FullName); + Assert.Equal(true, forkCreated.Fork); + } + + [IntegrationTest] + public async Task ForkCreatedForOrganization() + { + // The fork is created asynchronially by github and therefore it cannot + // be certain that the repo exists when the test ends. It is therefore deleted + // before the test starts. + Helper.DeleteRepo(Helper.Organization, "octokit.net"); + + var github = Helper.GetAuthenticatedClient(); + + var forkCreated = await github.Repository.Forks.Create("octokit", "octokit.net", new NewRepositoryFork { Organization = Helper.Organization }); + + Assert.NotNull(forkCreated); + Assert.Equal(String.Format("{0}/octokit.net", Helper.Organization), forkCreated.FullName); + Assert.Equal(true, forkCreated.Fork); + } + } + } +} diff --git a/Octokit.Tests.Integration/Octokit.Tests.Integration.csproj b/Octokit.Tests.Integration/Octokit.Tests.Integration.csproj index d6cc66a1..e0bc1b37 100644 --- a/Octokit.Tests.Integration/Octokit.Tests.Integration.csproj +++ b/Octokit.Tests.Integration/Octokit.Tests.Integration.csproj @@ -87,6 +87,7 @@ +