Skip to content

Commit

Permalink
fix tests and use string
Browse files Browse the repository at this point in the history
  • Loading branch information
ryfu-msft committed Nov 20, 2024
1 parent 97635a5 commit fd1dc94
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 27 deletions.
4 changes: 2 additions & 2 deletions src/AppInstallerCLICore/ConfigurationCommon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ namespace AppInstaller::CLI
struct ModulePathInfo
{
SetProcessorFactory::PwshConfigurationProcessorLocation location;
std::optional<std::string_view> customLocation;
std::optional<std::string> customLocation;
};

ModulePathInfo GetModulePathInfo(Execution::Args& execArgs)
Expand All @@ -44,7 +44,7 @@ namespace AppInstaller::CLI
}
else
{
return { SetProcessorFactory::PwshConfigurationProcessorLocation::Custom, execArgs.GetArg(Execution::Args::Type::ConfigurationModulePath) };
return { SetProcessorFactory::PwshConfigurationProcessorLocation::Custom, std::string(execArgs.GetArg(Execution::Args::Type::ConfigurationModulePath)) };
}
}

Expand Down
50 changes: 25 additions & 25 deletions src/AppInstallerCLIE2ETests/ConfigureCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,31 @@ public void ConfigureFromTestRepo()
Constants.SimpleTestModuleName)));
}

/// <summary>
/// Simple test to confirm that the module was installed to the location specified in the DefaultModuleRoot settings.
/// </summary>
[Test]
public void ConfigureFromTestRepo_DefaultModuleRootSetting()
{
TestCommon.EnsureModuleState(Constants.SimpleTestModuleName, present: false);
string moduleTestDir = TestCommon.GetRandomTestDir();
WinGetSettingsHelper.ConfigureConfigureBehavior(Constants.DefaultModuleRoot, moduleTestDir);

string args = TestCommon.GetTestDataFile("Configuration\\Configure_TestRepo_Location.yml");
var result = TestCommon.RunAICLICommand(CommandAndAgreementsAndVerbose, args);

WinGetSettingsHelper.ConfigureConfigureBehavior(Constants.DefaultModuleRoot, string.Empty);
bool moduleExists = Directory.Exists(Path.Combine(moduleTestDir, Constants.SimpleTestModuleName));
if (moduleExists)
{
// Clean test directory to avoid impacting other tests.
Directory.Delete(moduleTestDir, true);
}

Assert.AreEqual(0, result.ExitCode);
Assert.True(moduleExists);
}

/// <summary>
/// Simple test to confirm that the module was installed in the right location.
/// </summary>
Expand Down Expand Up @@ -115,31 +140,6 @@ public void ConfigureFromTestRepo_Location(TestCommon.TestModuleLocation locatio
Constants.SimpleTestModuleName)));
}

/// <summary>
/// Simple test to confirm that the module was installed to the location specified in the DefaultModuleRoot settings.
/// </summary>
// [Test]
public void ConfigureFromTestRepo_SettingsDefaultModuleRoot()
{
TestCommon.EnsureModuleState(Constants.SimpleTestModuleName, present: false);
string moduleTestDir = TestCommon.GetRandomTestDir();
WinGetSettingsHelper.ConfigureConfigureBehavior(Constants.DefaultModuleRoot, moduleTestDir);

string args = TestCommon.GetTestDataFile("Configuration\\Configure_TestRepo_Location.yml");
var result = TestCommon.RunAICLICommand(CommandAndAgreementsAndVerbose, args);

WinGetSettingsHelper.ConfigureInstallBehavior(Constants.DefaultModuleRoot, string.Empty);
bool moduleExists = Directory.Exists(Path.Combine(moduleTestDir, Constants.SimpleTestModuleName));
if (moduleExists)
{
// Clean test directory to avoid impacting other tests.
Directory.Delete(moduleTestDir, true);
}

Assert.AreEqual(0, result.ExitCode);
Assert.True(moduleExists);
}

/// <summary>
/// One resource fails, but the other is not dependent and should be executed.
/// </summary>
Expand Down

0 comments on commit fd1dc94

Please sign in to comment.