From ee49ff959f384242c5503289a2ceb0fef5bdbf28 Mon Sep 17 00:00:00 2001 From: Briana J Date: Mon, 29 Jan 2024 20:34:07 +0000 Subject: [PATCH] add migrate org coverage --- .../Commands/MigrateOrg/MigrateOrgCommandHandlerTests.cs | 3 +++ src/gei/Commands/MigrateOrg/MigrateOrgCommand.cs | 7 ++++++- src/gei/Commands/MigrateOrg/MigrateOrgCommandArgs.cs | 1 + 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/OctoshiftCLI.Tests/gei/Commands/MigrateOrg/MigrateOrgCommandHandlerTests.cs b/src/OctoshiftCLI.Tests/gei/Commands/MigrateOrg/MigrateOrgCommandHandlerTests.cs index 9e12cdd90..6a994f9b6 100644 --- a/src/OctoshiftCLI.Tests/gei/Commands/MigrateOrg/MigrateOrgCommandHandlerTests.cs +++ b/src/OctoshiftCLI.Tests/gei/Commands/MigrateOrg/MigrateOrgCommandHandlerTests.cs @@ -22,6 +22,7 @@ public class MigrateOrgCommandHandlerTests private const string TARGET_ORG = "foo-target-org"; private const string SOURCE_PAT = "foo-source-pat"; private const string TARGET_PAT = "foo-target-pat"; + private const string TARGET_API_URL = "https://api.github.com"; public MigrateOrgCommandHandlerTests() { @@ -119,6 +120,7 @@ public async Task Happy_Path_PAT_In_Env() GithubSourceOrg = SOURCE_ORG, GithubTargetOrg = TARGET_ORG, GithubTargetEnterprise = TARGET_ENTERPRISE, + TargetApiUrl = TARGET_API_URL, }; await _handler.Handle(args); @@ -155,6 +157,7 @@ public async Task Queue_Only() GithubTargetOrg = TARGET_ORG, GithubTargetEnterprise = TARGET_ENTERPRISE, GithubTargetPat = TARGET_PAT, + TargetApiUrl = TARGET_API_URL, QueueOnly = true, }; await _handler.Handle(args); diff --git a/src/gei/Commands/MigrateOrg/MigrateOrgCommand.cs b/src/gei/Commands/MigrateOrg/MigrateOrgCommand.cs index 10d4658c2..b4c733433 100644 --- a/src/gei/Commands/MigrateOrg/MigrateOrgCommand.cs +++ b/src/gei/Commands/MigrateOrg/MigrateOrgCommand.cs @@ -16,6 +16,7 @@ public MigrateOrgCommand() : base( AddOption(GithubSourceOrg); AddOption(GithubTargetOrg); AddOption(GithubTargetEnterprise); + AddOption(TargetApiUrl); AddOption(GithubSourcePat); AddOption(GithubTargetPat); @@ -40,6 +41,10 @@ public MigrateOrgCommand() : base( }; public Option GithubSourcePat { get; } = new("--github-source-pat"); public Option GithubTargetPat { get; } = new("--github-target-pat"); + public Option TargetApiUrl { get; } = new("--target-api-url") + { + Description = "The URL of the target API, if not migrating to github.com. Defaults to https://api.github.com" + }; public Option QueueOnly { get; } = new("--queue-only") { Description = "Only queues the migration, does not wait for it to finish. Use the wait-for-migration command to subsequently wait for it to finish and view the status." @@ -62,7 +67,7 @@ public override MigrateOrgCommandHandler BuildHandler(MigrateOrgCommandArgs args var environmentVariableProvider = sp.GetRequiredService(); var targetGithubApiFactory = sp.GetRequiredService(); - var targetGithubApi = targetGithubApiFactory.Create(targetPersonalAccessToken: args.GithubTargetPat); + var targetGithubApi = targetGithubApiFactory.Create(args.TargetApiUrl, args.GithubTargetPat); return new MigrateOrgCommandHandler(log, targetGithubApi, environmentVariableProvider); } diff --git a/src/gei/Commands/MigrateOrg/MigrateOrgCommandArgs.cs b/src/gei/Commands/MigrateOrg/MigrateOrgCommandArgs.cs index 036e42f62..c1532ee95 100644 --- a/src/gei/Commands/MigrateOrg/MigrateOrgCommandArgs.cs +++ b/src/gei/Commands/MigrateOrg/MigrateOrgCommandArgs.cs @@ -14,6 +14,7 @@ public class MigrateOrgCommandArgs : CommandArgs public string GithubSourcePat { get; set; } [Secret] public string GithubTargetPat { get; set; } + public string TargetApiUrl { get; set; } public override void Validate(OctoLogger log) {