Skip to content

Commit

Permalink
add migrate org coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
brianaj committed Jan 29, 2024
1 parent 169c0c8 commit ee49ff9
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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()
{
Expand Down Expand Up @@ -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);

Expand Down Expand Up @@ -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);
Expand Down
7 changes: 6 additions & 1 deletion src/gei/Commands/MigrateOrg/MigrateOrgCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ public MigrateOrgCommand() : base(
AddOption(GithubSourceOrg);
AddOption(GithubTargetOrg);
AddOption(GithubTargetEnterprise);
AddOption(TargetApiUrl);

AddOption(GithubSourcePat);
AddOption(GithubTargetPat);
Expand All @@ -40,6 +41,10 @@ public MigrateOrgCommand() : base(
};
public Option<string> GithubSourcePat { get; } = new("--github-source-pat");
public Option<string> GithubTargetPat { get; } = new("--github-target-pat");
public Option<string> 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<bool> 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."
Expand All @@ -62,7 +67,7 @@ public override MigrateOrgCommandHandler BuildHandler(MigrateOrgCommandArgs args
var environmentVariableProvider = sp.GetRequiredService<EnvironmentVariableProvider>();

var targetGithubApiFactory = sp.GetRequiredService<ITargetGithubApiFactory>();
var targetGithubApi = targetGithubApiFactory.Create(targetPersonalAccessToken: args.GithubTargetPat);
var targetGithubApi = targetGithubApiFactory.Create(args.TargetApiUrl, args.GithubTargetPat);

return new MigrateOrgCommandHandler(log, targetGithubApi, environmentVariableProvider);
}
Expand Down
1 change: 1 addition & 0 deletions src/gei/Commands/MigrateOrg/MigrateOrgCommandArgs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down

0 comments on commit ee49ff9

Please sign in to comment.