Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BREAKING CHANGE: Drop support for deprecated --wait option in migrate-repo and migrate-org #1083

Merged
merged 5 commits into from
Aug 2, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion RELEASENOTES.md
Original file line number Diff line number Diff line change
@@ -1 +1 @@

- __BREAKING CHANGE__: Drop support for the deprecated `--wait` option in `migrate-repo` and `migrate-org`. Three months ago, we made waiting for the migration to finish the default behavior and added a new `--queue-only` option. For backwards compatibility reasons, we continued to allow the `--wait` argument and printed warnings if it was specified. From this release onwards, specifying the `--wait` argument will cause the CLI to error.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -209,8 +209,7 @@ public async Task Happy_Path_With_Wait()
AdoTeamProject = ADO_TEAM_PROJECT,
AdoRepo = ADO_REPO,
GithubOrg = GITHUB_ORG,
GithubRepo = GITHUB_REPO,
Wait = true,
GithubRepo = GITHUB_REPO
timrogers marked this conversation as resolved.
Show resolved Hide resolved
};
await _handler.Handle(args);

Expand Down Expand Up @@ -240,8 +239,7 @@ await _handler.Invoking(async x => await x.Handle(new MigrateRepoCommandArgs
AdoTeamProject = ADO_TEAM_PROJECT,
AdoRepo = ADO_REPO,
GithubOrg = GITHUB_ORG,
GithubRepo = GITHUB_REPO,
Wait = true,
GithubRepo = GITHUB_REPO
timrogers marked this conversation as resolved.
Show resolved Hide resolved
}))
.Should()
.ThrowAsync<OctoshiftCliException>()
Expand All @@ -267,8 +265,7 @@ public async Task It_Falls_Back_To_Ado_And_Github_Pats_From_Environment_When_Not
AdoTeamProject = ADO_TEAM_PROJECT,
AdoRepo = ADO_REPO,
GithubOrg = GITHUB_ORG,
GithubRepo = GITHUB_REPO,
Wait = true,
GithubRepo = GITHUB_REPO
timrogers marked this conversation as resolved.
Show resolved Hide resolved
};

await _handler.Handle(args);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,43 +33,19 @@ public void Should_Have_Options()
{
_command.Should().NotBeNull();
_command.Name.Should().Be("migrate-repo");
_command.Options.Count.Should().Be(12);
_command.Options.Count.Should().Be(11);

TestHelpers.VerifyCommandOption(_command.Options, "ado-org", true);
TestHelpers.VerifyCommandOption(_command.Options, "ado-team-project", true);
TestHelpers.VerifyCommandOption(_command.Options, "ado-repo", true);
TestHelpers.VerifyCommandOption(_command.Options, "github-org", true);
TestHelpers.VerifyCommandOption(_command.Options, "github-repo", true);
TestHelpers.VerifyCommandOption(_command.Options, "ado-server-url", false, true);
TestHelpers.VerifyCommandOption(_command.Options, "wait", false, true);
TestHelpers.VerifyCommandOption(_command.Options, "queue-only", false);
TestHelpers.VerifyCommandOption(_command.Options, "target-repo-visibility", false);
TestHelpers.VerifyCommandOption(_command.Options, "ado-pat", false);
TestHelpers.VerifyCommandOption(_command.Options, "github-pat", false);
TestHelpers.VerifyCommandOption(_command.Options, "verbose", false);
}

[Fact]
public void It_Uses_Github_Pat_When_Provided()
{
var adoPat = "abc123";
var githubPat = "def456";

var args = new MigrateRepoCommandArgs
{
AdoOrg = "foo-org",
AdoTeamProject = "blah-tp",
AdoRepo = "some-repo",
GithubOrg = "gh-org",
GithubRepo = "gh-repo",
Wait = true,
AdoPat = adoPat,
GithubPat = githubPat,
};

_command.BuildHandler(args, _serviceProvider);

_mockGithubApiFactory.Verify(m => m.Create(null, githubPat));
}
timrogers marked this conversation as resolved.
Show resolved Hide resolved
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -344,70 +344,6 @@ public void It_Throws_If_Archive_Url_Is_Provided_But_Github_Repo_Is_Not()
.WithMessage("*--github-repo*");
}

[Fact]
public void Validates_Wait_And_QueueOnly_Not_Passed_Together()
{
var args = new MigrateRepoCommandArgs
{
BbsProject = BBS_PROJECT,
BbsRepo = BBS_REPO,
BbsServerUrl = BBS_SERVER_URL,
BbsUsername = BBS_USERNAME,
BbsPassword = BBS_PASSWORD,
AzureStorageConnectionString = AZURE_STORAGE_CONNECTION_STRING,
GithubOrg = GITHUB_ORG,
GithubRepo = GITHUB_REPO,
Wait = true,
QueueOnly = true,
};

args.Invoking(x => x.Validate(_mockOctoLogger.Object))
.Should()
.ThrowExactly<OctoshiftCliException>()
.WithMessage("*wait*");
}

[Fact]
public void Wait_Flag_Shows_Warning()
{
var args = new MigrateRepoCommandArgs
{
BbsProject = BBS_PROJECT,
BbsRepo = BBS_REPO,
BbsServerUrl = BBS_SERVER_URL,
BbsUsername = BBS_USERNAME,
BbsPassword = BBS_PASSWORD,
AzureStorageConnectionString = AZURE_STORAGE_CONNECTION_STRING,
GithubOrg = GITHUB_ORG,
GithubRepo = GITHUB_REPO,
Wait = true,
};

args.Validate(_mockOctoLogger.Object);

_mockOctoLogger.Verify(x => x.LogWarning(It.Is<string>(x => x.ToLower().Contains("wait"))));
}

[Fact]
public void No_Wait_And_No_Queue_Only_Flags_Shows_Warning()
{
var args = new MigrateRepoCommandArgs
{
BbsProject = BBS_PROJECT,
BbsRepo = BBS_REPO,
BbsServerUrl = BBS_SERVER_URL,
BbsUsername = BBS_USERNAME,
BbsPassword = BBS_PASSWORD,
AzureStorageConnectionString = AZURE_STORAGE_CONNECTION_STRING,
GithubOrg = GITHUB_ORG,
GithubRepo = GITHUB_REPO,
};

args.Validate(_mockOctoLogger.Object);

_mockOctoLogger.Verify(x => x.LogWarning(It.Is<string>(x => x.ToLower().Contains("wait"))));
}

[Fact]
public void Invoke_With_Bbs_Server_Url_Throws_When_Both_Ssh_User_And_Smb_User_Are_Provided()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -527,8 +527,7 @@ public async Task Throws_An_Error_If_Export_Fails()
BbsUsername = BBS_USERNAME,
BbsPassword = BBS_PASSWORD,
BbsProject = BBS_PROJECT,
BbsRepo = BBS_REPO,
Wait = true
BbsRepo = BBS_REPO
timrogers marked this conversation as resolved.
Show resolved Hide resolved
};

// Assert
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public void Should_Have_Options()
var command = new MigrateRepoCommand();
command.Should().NotBeNull();
command.Name.Should().Be("migrate-repo");
command.Options.Count.Should().Be(31);
command.Options.Count.Should().Be(30);

TestHelpers.VerifyCommandOption(command.Options, "bbs-server-url", true);
TestHelpers.VerifyCommandOption(command.Options, "bbs-project", true);
Expand All @@ -79,7 +79,6 @@ public void Should_Have_Options()
TestHelpers.VerifyCommandOption(command.Options, "smb-user", false);
TestHelpers.VerifyCommandOption(command.Options, "smb-password", false);
TestHelpers.VerifyCommandOption(command.Options, "smb-domain", false);
TestHelpers.VerifyCommandOption(command.Options, "wait", false, true);
TestHelpers.VerifyCommandOption(command.Options, "queue-only", false);
TestHelpers.VerifyCommandOption(command.Options, "target-repo-visibility", false);
TestHelpers.VerifyCommandOption(command.Options, "kerberos", false, true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,67 +13,8 @@ public class MigrateOrgCommandArgsTests
private const string TARGET_ENTERPRISE = "foo-target-ent";
private const string SOURCE_ORG = "foo-source-org";
private const string TARGET_ORG = "foo-target-org";
private const string SOURCE_PAT = "foo-source-pat";
private const string TARGET_PAT = "foo-target-pat";

[Fact]
public void Validates_Wait_And_QueueOnly_Not_Passed_Together()
{
// Act
var args = new MigrateOrgCommandArgs
{
GithubSourceOrg = SOURCE_ORG,
GithubSourcePat = SOURCE_PAT,
GithubTargetOrg = TARGET_ORG,
GithubTargetEnterprise = TARGET_ENTERPRISE,
GithubTargetPat = TARGET_PAT,
Wait = true,
QueueOnly = true,
};

FluentActions.Invoking(() => args.Validate(_mockOctoLogger.Object))
.Should()
.ThrowExactly<OctoshiftCliException>()
.WithMessage("*wait*");
}

[Fact]
public void Wait_Flag_Shows_Warning()
{
var args = new MigrateOrgCommandArgs
{
GithubSourceOrg = SOURCE_ORG,
GithubSourcePat = SOURCE_PAT,
GithubTargetOrg = TARGET_ORG,
GithubTargetEnterprise = TARGET_ENTERPRISE,
GithubTargetPat = TARGET_PAT,
Wait = true,
};

args.Validate(_mockOctoLogger.Object);

_mockOctoLogger.Verify(x => x.LogWarning(It.Is<string>(x => x.ToLower().Contains("wait"))));
}

[Fact]
public void No_Wait_And_No_Queue_Only_Flags_Shows_Warning()
{
var args = new MigrateOrgCommandArgs
{
GithubSourceOrg = SOURCE_ORG,
GithubSourcePat = SOURCE_PAT,
GithubTargetOrg = TARGET_ORG,
GithubTargetEnterprise = TARGET_ENTERPRISE,
GithubTargetPat = TARGET_PAT,
Wait = false,
QueueOnly = false,
};

args.Validate(_mockOctoLogger.Object);

_mockOctoLogger.Verify(x => x.LogWarning(It.Is<string>(x => x.ToLower().Contains("wait"))));
}

[Fact]
public void Source_Pat_Defaults_To_Target_Pat()
{
Expand All @@ -82,8 +23,7 @@ public void Source_Pat_Defaults_To_Target_Pat()
GithubSourceOrg = SOURCE_ORG,
GithubTargetOrg = TARGET_ORG,
GithubTargetEnterprise = TARGET_ENTERPRISE,
GithubTargetPat = TARGET_PAT,
Wait = true,
GithubTargetPat = TARGET_PAT
timrogers marked this conversation as resolved.
Show resolved Hide resolved
};

args.Validate(_mockOctoLogger.Object);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,7 @@ public async Task Happy_Path()
GithubSourcePat = SOURCE_PAT,
GithubTargetOrg = TARGET_ORG,
GithubTargetEnterprise = TARGET_ENTERPRISE,
GithubTargetPat = TARGET_PAT,
Wait = true,
GithubTargetPat = TARGET_PAT
timrogers marked this conversation as resolved.
Show resolved Hide resolved
};
await _handler.Handle(args);

Expand Down Expand Up @@ -119,8 +118,7 @@ public async Task Happy_Path_PAT_In_Env()
{
GithubSourceOrg = SOURCE_ORG,
GithubTargetOrg = TARGET_ORG,
GithubTargetEnterprise = TARGET_ENTERPRISE,
Wait = true,
GithubTargetEnterprise = TARGET_ENTERPRISE
timrogers marked this conversation as resolved.
Show resolved Hide resolved
};
await _handler.Handle(args);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,11 @@ public void Should_Have_Options()
var command = new MigrateOrgCommand();
command.Should().NotBeNull();
command.Name.Should().Be("migrate-org");
command.Options.Count.Should().Be(8);
command.Options.Count.Should().Be(7);

TestHelpers.VerifyCommandOption(command.Options, "github-source-org", true);
TestHelpers.VerifyCommandOption(command.Options, "github-target-org", true);
TestHelpers.VerifyCommandOption(command.Options, "github-target-enterprise", true);
TestHelpers.VerifyCommandOption(command.Options, "wait", false, true);
TestHelpers.VerifyCommandOption(command.Options, "queue-only", false);
TestHelpers.VerifyCommandOption(command.Options, "github-source-pat", false);
TestHelpers.VerifyCommandOption(command.Options, "github-target-pat", false);
Expand Down
Loading