<commit_before>﻿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);
        }
    }
}<commit_msg>Migrations API: Added deletion integration tests.<commit_after>﻿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);
        }
    }

    public class TheDeleteArchiveMethod
    {
        readonly IGitHubClient _gitHub;

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

        [IntegrationTest]
        public async Task DeletesArchive()
        {
            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);

            await _gitHub.Migration.Migrations.DeleteArchive(organization, migration.Id);
        }
    }

    public class TheUnlockRepositoryMethod
    {
        readonly IGitHubClient _gitHub;

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

        [IntegrationTest]
        public async Task UnlocksRepository()
        {
            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, true);
            var migration = await _gitHub.Migration.Migrations.Start(organization, migrationRequest);

            await _gitHub.Migration.Migrations.UnlockRepository(organization, migration.Id, migration.Repositories[0].FullName);
        }
    }
}
{'fraction_non_alphanumeric': 0.08122188017996684, 'fraction_numerical': 0.0003551977267345489, 'mean_word_length': 2.5656395103419163, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5709829', 'n_tokens_mistral': 2260, 'n_tokens_neox': 2168, 'n_words': 411}