Skip to content

Commit

Permalink
Add integration tests for Migrations API.
Browse files Browse the repository at this point in the history
  • Loading branch information
devkhan committed Mar 30, 2016
1 parent 1875297 commit 16593eb
Show file tree
Hide file tree
Showing 2 changed files with 104 additions and 0 deletions.
103 changes: 103 additions & 0 deletions Octokit.Tests.Integration/Clients/MigrationsClientTests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Octokit;
using Octokit.Tests.Integration;
using Xunit;

public class MigrationsClientTests
{
public class TheStartNewMethod
{
readonly IGitHubClient _gitHub;

public TheStartNewMethod()
{
_gitHub = Helper.GetAuthenticatedClient();

}

[IntegrationTest]
public async Task CanStartNewMigration()
{
var organization = Environment.GetEnvironmentVariable("OCTOKIT_GITHUBORGANIZATION");
var repos = (await _gitHub.Repository.GetAllForOrg(organization));
var repoNames = repos.Select(repo => repo.FullName).ToList();
var migrationRequest = new StartMigrationRequest(repoNames);

var migration = await _gitHub.Migration.Migrations.Start(organization, migrationRequest);

Assert.Equal(repos.Count, migration.Repositories.Count);
Assert.Equal("pending", migration.State);
}
}

public class TheGetAllMethod
{
readonly IGitHubClient _gitHub;

public TheGetAllMethod()
{
_gitHub = Helper.GetAuthenticatedClient();
}

[IntegrationTest]
public async Task CanGetAllMigrations()
{
var organization = Environment.GetEnvironmentVariable("OCTOKIT_GITHUBORGANIZATION");
var migrations = await _gitHub.Migration.Migrations.GetAll(organization);

Assert.NotNull(migrations);
Assert.NotEqual(0, migrations.Count);
}
}

public class TheGetMethod
{
readonly IGitHubClient _gitHub;

public TheGetMethod()
{
_gitHub = Helper.GetAuthenticatedClient();
}

[IntegrationTest]
public async Task CanGetMigration()
{
var organization = Environment.GetEnvironmentVariable("OCTOKIT_GITHUBORGANIZATION");
var repos = (await _gitHub.Repository.GetAllForOrg(organization));
var repoNames = repos.Select(repo => repo.FullName).ToList();
var migrationRequest = new StartMigrationRequest(repoNames);
var migration = await _gitHub.Migration.Migrations.Start(organization, migrationRequest);

var retreivedMigration = await _gitHub.Migration.Migrations.Get(organization, migration.Id);

Assert.Equal(migration.Guid, retreivedMigration.Guid);
}
}

public class TheGetArchiveMethod
{
readonly IGitHubClient _gitHub;

public TheGetArchiveMethod()
{
_gitHub = Helper.GetAuthenticatedClient();
}

[IntegrationTest]
public async Task CanGetArchive()
{
var organization = Environment.GetEnvironmentVariable("OCTOKIT_GITHUBORGANIZATION");
var repos = (await _gitHub.Repository.GetAllForOrg(organization));
var repoNames = repos.Select(repo => repo.FullName).ToList();
var migrationRequest = new StartMigrationRequest(repoNames);
var migration = await _gitHub.Migration.Migrations.Start(organization, migrationRequest);

var url = await _gitHub.Migration.Migrations.GetArchive(organization, migration.Id);

Assert.NotEmpty(url);
}
}
}
1 change: 1 addition & 0 deletions Octokit.Tests.Integration/Octokit.Tests.Integration.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@
<Compile Include="Clients\IssuesLabelsClientTests.cs" />
<Compile Include="Clients\GistsClientTests.cs" />
<Compile Include="Clients\IssuesEventsClientTests.cs" />
<Compile Include="Clients\MigrationsClientTests.cs" />
<Compile Include="Clients\MilestonesClientTests.cs" />
<Compile Include="Clients\OrganizationMembersClientTests.cs" />
<Compile Include="Clients\PullRequestsClientTests.cs" />
Expand Down

0 comments on commit 16593eb

Please sign in to comment.