Skip to content

Commit 620730d

Browse files
committed
Fix tests and remove pre setup
1 parent 2bb1d7d commit 620730d

File tree

3 files changed

+12
-28
lines changed

3 files changed

+12
-28
lines changed

azure-pipelines.yml

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -371,12 +371,6 @@ jobs:
371371
displayName: Clean up Sysinternals PsTools
372372
condition: succeededOrFailed()
373373
374-
# Install required DSC modules until export all command can handle auto acquisition
375-
- pwsh: |
376-
Install-Module -Name Microsoft.Windows.Settings -AllowPrerelease -Force
377-
displayName: Install Required DSC Modules for Tests
378-
condition: succeededOrFailed()
379-
380374
- task: PowerShell@2
381375
displayName: Run Unit Tests Packaged
382376
inputs:

src/AppInstallerCLICore/Workflows/ConfigurationFlow.cpp

Lines changed: 11 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1255,7 +1255,7 @@ namespace AppInstaller::CLI::Workflow
12551255
return unit;
12561256
}
12571257

1258-
ValueSet CreateValueSetFromStringArray(const std::vector<std::wstring>& values)
1258+
ValueSet CreateValueSetFromStringVector(const std::vector<std::wstring>& values)
12591259
{
12601260
ValueSet result;
12611261
size_t index = 0;
@@ -1287,7 +1287,7 @@ namespace AppInstaller::CLI::Workflow
12871287
L"-Command",
12881288
L"if (-not (Get-Module -ListAvailable -Name " + moduleNameString + L")) { Install-Module -Name " + moduleNameString + L" -Confirm:$False -Force -AllowPrerelease -AllowClobber }"
12891289
};
1290-
settings.Insert(L"arguments", CreateValueSetFromStringArray(arguments));
1290+
settings.Insert(L"arguments", CreateValueSetFromStringVector(arguments));
12911291
unit.Settings(settings);
12921292

12931293
unit.Dependencies().Append(dependentUnit.Identifier());
@@ -1574,22 +1574,18 @@ namespace AppInstaller::CLI::Workflow
15741574
{
15751575
ConfigurationContext& configContext = context.Get<Data::ConfigurationContext>();
15761576

1577-
// PowerShell package needs to be present for later certain predefined modules to work.
1578-
std::optional<ConfigurationUnit> powerShellPackageUnit = CreatePowerShellPackageUnit();
1577+
// PowerShell package needs to be present for certain predefined modules to work.
1578+
ConfigurationUnit powerShellPackageUnit = CreatePowerShellPackageUnit();
1579+
configContext.Set().Units().Append(powerShellPackageUnit);
15791580

15801581
// Apply the unit to make sure it's on the system.
1581-
context.Reporter.Info() << Resource::String::ConfigurationExportInstallRequiredModule(Utility::LocIndView{ "Microsoft PowerShell" }) << std::endl;
1582-
auto applyPowerShellResult = ApplyUnit(context, powerShellPackageUnit.value());
1583-
if (SUCCEEDED(applyPowerShellResult.ResultInformation().ResultCode()))
1582+
context.Reporter.Info() << Resource::String::ConfigurationExportInstallRequiredModule(Utility::LocIndView{ "Microsoft PowerShell Package" }) << std::endl;
1583+
auto applyPowerShellResult = ApplyUnit(context, powerShellPackageUnit);
1584+
if (FAILED(applyPowerShellResult.ResultInformation().ResultCode()))
15841585
{
1585-
configContext.Set().Units().Append(powerShellPackageUnit.value());
1586-
}
1587-
else
1588-
{
1589-
AICLI_LOG(Config, Warning, << "Failed to ensure module. [Microsoft PowerShell] Related settings will not be exported.");
1590-
LogFailedGetConfigurationUnitDetails(powerShellPackageUnit.value(), applyPowerShellResult.ResultInformation());
1586+
AICLI_LOG(Config, Warning, << "Failed to ensure module. [Microsoft PowerShell Package] Related settings may not be exported.");
1587+
LogFailedGetConfigurationUnitDetails(powerShellPackageUnit, applyPowerShellResult.ResultInformation());
15911588
context.Reporter.Warn() << Resource::String::ConfigurationExportInstallRequiredModuleFailed << std::endl;
1592-
powerShellPackageUnit = std::nullopt;
15931589
}
15941590

15951591
for (const auto& resources : PredefinedResourcesForExport())
@@ -1598,13 +1594,7 @@ namespace AppInstaller::CLI::Workflow
15981594

15991595
if (!resources.RequiredModule.empty())
16001596
{
1601-
if (!powerShellPackageUnit)
1602-
{
1603-
// PowerShell package not present, skip.
1604-
continue;
1605-
}
1606-
1607-
requiredModuleUnit = CreateRequiredModuleUnit(resources.RequiredModule, powerShellPackageUnit.value());
1597+
requiredModuleUnit = CreateRequiredModuleUnit(resources.RequiredModule, powerShellPackageUnit);
16081598

16091599
// Apply the unit to make sure it's on the system.
16101600
context.Reporter.Info() << Resource::String::ConfigurationExportInstallRequiredModule(Utility::LocIndView{ Utility::ConvertToUTF8(resources.RequiredModule) }) << std::endl;

src/AppInstallerCLIE2ETests/ConfigureCommand.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -400,7 +400,7 @@ public void RunCommandOnSetResourceTest()
400400
var testConfigFile = Path.Combine(testDir, "RunCommandOnSet.yml");
401401
File.Copy(TestCommon.GetTestDataFile("Configuration\\RunCommandOnSet.yml"), testConfigFile);
402402

403-
var result = TestCommon.RunAICLICommand(CommandAndAgreementsAndVerbose, TestCommon.GetTestDataFile("Configuration\\RunCommandOnSet.yml"), timeOut: 300000);
403+
var result = TestCommon.RunAICLICommand(CommandAndAgreementsAndVerbose, testConfigFile, timeOut: 300000);
404404
Assert.AreEqual(0, result.ExitCode);
405405

406406
// Verify test file created.

0 commit comments

Comments
 (0)