Skip to content

Commit

Permalink
fix E2E tests part 2
Browse files Browse the repository at this point in the history
  • Loading branch information
ryfu-msft committed Nov 14, 2023
1 parent a5dfeb6 commit 1750404
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/AppInstallerCLICore/Workflows/InstallFlow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -485,7 +485,7 @@ namespace AppInstaller::CLI::Workflow
terminationHR = S_OK;
break;
case APPINSTALLER_CLI_ERROR_INSTALL_REBOOT_REQUIRED_FOR_INSTALL:
// REBOOT_REQUIRED_TO_INSTALL is treated as an error since installation has not yet completed.
// REBOOT_REQUIRED_FOR_INSTALL is treated as an error since installation has not yet completed.
context.SetFlags(ContextFlag::RebootRequired);
// TODO: Add separate workflow to handle restart registration for resume.
context.SetFlags(ContextFlag::RegisterResume);
Expand Down
13 changes: 8 additions & 5 deletions src/AppInstallerCLIE2ETests/ResumeCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,9 @@ public void InstallRequiresRebootToFinish()

var installDir = TestCommon.GetRandomTestDir();
var result = TestCommon.RunAICLICommand("install", $"TestRebootRequired --custom \"/ExitCode 9\" -l {installDir}");
Assert.AreNotEqual(Constants.ErrorCode.ERROR_INSTALL_REBOOT_REQUIRED_TO_FINISH, result.ExitCode);

// REBOOT_REQUIRED_TO_FINISH is treated as a success.
Assert.AreEqual(Constants.ErrorCode.S_OK, result.ExitCode);
Assert.True(result.StdOut.Contains("Restart your PC to finish installation."));
Assert.True(TestCommon.VerifyTestExeInstalledAndCleanup(installDir));

Expand All @@ -89,18 +91,18 @@ public void InstallRequiresRebootToFinish()
}

/// <summary>
/// Test install a package that returns REBOOT_REQUIRED_TO_INSTALL and verify that resume command can be called successfully.
/// Test install a package that returns REBOOT_REQUIRED_FOR_INSTALL and verify that resume command can be called successfully.
/// </summary>
[Test]
public void InstallRequiresRebootToInstall()
public void InstallRequiresRebootForInstall()
{
var checkpointsDir = TestCommon.GetCheckpointsDirectory();

int initialCheckpointsCount = Directory.Exists(checkpointsDir) ? Directory.GetDirectories(checkpointsDir).Length : 0;

var installDir = TestCommon.GetRandomTestDir();
var result = TestCommon.RunAICLICommand("install", $"TestRebootRequired --custom \"ExitCode 10\" -l {installDir}");
Assert.AreNotEqual(Constants.ErrorCode.ERROR_INSTALL_REBOOT_REQUIRED_FOR_INSTALL, result.ExitCode);
var result = TestCommon.RunAICLICommand("install", $"TestRebootRequired --custom \"/ExitCode 10\" -l {installDir}");
Assert.AreEqual(Constants.ErrorCode.ERROR_INSTALL_REBOOT_REQUIRED_FOR_INSTALL, result.ExitCode);
Assert.True(result.StdOut.Contains("Installation failed. Restart your PC then try again."));
Assert.True(TestCommon.VerifyTestExeInstalledAndCleanup(installDir));

Expand All @@ -117,6 +119,7 @@ public void InstallRequiresRebootToInstall()
var resumeResult = TestCommon.RunAICLICommand("resume", $"-g {checkpoint.Name}");
Assert.AreNotEqual(Constants.ErrorCode.ERROR_INSTALL_REBOOT_REQUIRED_FOR_INSTALL, resumeResult.ExitCode);
Assert.True(resumeResult.StdOut.Contains("Installation failed. Restart your PC then try again."));
Assert.True(TestCommon.VerifyTestExeInstalledAndCleanup(installDir));
}
}
}

0 comments on commit 1750404

Please sign in to comment.