mirror of
https://github.com/zoriya/octokit.net.git
synced 2026-06-03 19:11:30 +00:00
Add integration tests for Migrations API.
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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" />
|
||||
|
||||
Reference in New Issue
Block a user