Skip to content

Commit 603b97b

Browse files
committed
PR feedback
1 parent ba66176 commit 603b97b

File tree

8 files changed

+46
-22
lines changed

8 files changed

+46
-22
lines changed

src/AppInstallerCLI.sln

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11

22
Microsoft Visual Studio Solution File, Format Version 12.00
3-
# Visual Studio Version 17
4-
VisualStudioVersion = 17.14.36811.4 d17.14
3+
# Visual Studio Version 18
4+
VisualStudioVersion = 18.0.11205.157
55
MinimumVisualStudioVersion = 10.0.40219.1
66
Project("{C7167F0D-BC9F-4E6E-AFE1-012C56B48DB5}") = "AppInstallerCLIPackage", "AppInstallerCLIPackage\AppInstallerCLIPackage.wapproj", "{6AA3791A-0713-4548-A357-87A323E7AC3A}"
77
ProjectSection(ProjectDependencies) = postProject

src/AppInstallerCLIE2ETests/DSCv3SourceResourceCommand.cs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -489,7 +489,12 @@ private static void AssertExistingSourceResourceData(SourceResourceData output,
489489
Assert.IsNotNull(output);
490490
Assert.True(output.Exist);
491491
Assert.AreEqual(DefaultSourceName, output.Name);
492-
Assert.AreEqual(argument, output.Argument);
492+
493+
if (argument != null)
494+
{
495+
Assert.AreEqual(argument, output.Argument);
496+
}
497+
493498
Assert.AreEqual(DefaultSourceType, output.Type);
494499

495500
if (trustLevel != null)

src/AppInstallerCLIPackage/Shared/Strings/en-us/winget.resw

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3536,7 +3536,7 @@ An unlocalized JSON fragment will follow on another line.</comment>
35363536
<comment>Column title for listing the new value.</comment>
35373537
</data>
35383538
<data name="SourcePriorityArgumentDescription" xml:space="preserve">
3539-
<value>Priority with higher numbers first</value>
3539+
<value>Priority; higher numbers first</value>
35403540
<comment>This argument sets the numerical priority of the source. Higher values will be first in priority.</comment>
35413541
</data>
35423542
<data name="SourceListPriority" xml:space="preserve">

src/AppInstallerCLITests/Sources.cpp

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -388,12 +388,10 @@ TEST_CASE("RepoSources_ThreeSources", "[sources]")
388388
SetSetting(Stream::UserSources, s_ThreeSources);
389389
SetSetting(Stream::SourcesMetadata, s_ThreeSourcesMetadata);
390390

391-
std::vector<SourceDetails> sources = GetSources();
392-
REQUIRE(sources.size() == 3);
393-
394-
const char* suffixUnsorted[3] = { "", "2", "3" };
395-
const char* suffixPrioritySorted[3] = { "2", "3", "" };
396-
const char** suffix = nullptr;
391+
const char* suffixStrings[3] = { "", "2", "3" };
392+
size_t suffixUnsorted[3] = { 0, 1, 2 };
393+
size_t suffixPrioritySorted[3] = { 1, 2, 0 };
394+
size_t* suffix = nullptr;
397395
std::unique_ptr<TestHook::SetSingleExperimentalFeature_Override> override;
398396

399397
SECTION("Unsorted")
@@ -406,15 +404,20 @@ TEST_CASE("RepoSources_ThreeSources", "[sources]")
406404
suffix = suffixPrioritySorted;
407405
}
408406

409-
for (size_t i = 0; i < 3; ++i)
407+
std::vector<SourceDetails> sources = GetSources();
408+
REQUIRE(sources.size() == 3);
409+
410+
for (size_t index = 0; index < 3; ++index)
410411
{
411-
INFO("Source #" << i);
412-
REQUIRE(sources[i].Name == "testName"s + suffix[i]);
413-
REQUIRE(sources[i].Type == "testType"s + suffix[i]);
414-
REQUIRE(sources[i].Arg == "testArg"s + suffix[i]);
415-
REQUIRE(sources[i].Data == "testData"s + suffix[i]);
416-
REQUIRE(sources[i].LastUpdateTime == ConvertUnixEpochToSystemClock(i));
417-
REQUIRE(sources[i].Origin == SourceOrigin::User);
412+
size_t i = suffix[index];
413+
414+
INFO("Source #" << index << " [" << i << "]");
415+
REQUIRE(sources[index].Name == "testName"s + suffixStrings[i]);
416+
REQUIRE(sources[index].Type == "testType"s + suffixStrings[i]);
417+
REQUIRE(sources[index].Arg == "testArg"s + suffixStrings[i]);
418+
REQUIRE(sources[index].Data == "testData"s + suffixStrings[i]);
419+
REQUIRE(sources[index].LastUpdateTime == ConvertUnixEpochToSystemClock(i));
420+
REQUIRE(sources[index].Origin == SourceOrigin::User);
418421
}
419422
}
420423

src/AppInstallerCLITests/TestSource.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -489,7 +489,10 @@ namespace TestCommon
489489

490490
bool AddSource(const AppInstaller::Repository::SourceDetails& details, AppInstaller::IProgressCallback& progress)
491491
{
492-
Repository::Source source{ details.Name, details.Arg, details.Type, Repository::SourceTrustLevel::None, {} };
492+
Repository::SourceEdit additionalProperties;
493+
additionalProperties.Explicit = details.Explicit;
494+
additionalProperties.Priority = details.Priority;
495+
Repository::Source source{ details.Name, details.Arg, details.Type, Repository::SourceTrustLevel::None, additionalProperties };
493496
return source.Add(progress);
494497
}
495498

src/PowerShell/Microsoft.WinGet.Client.Cmdlets/Cmdlets/AddSourceCmdlet.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,16 @@ public sealed class AddSourceCmdlet : PSCmdlet
4242
[Parameter(
4343
ValueFromPipeline = true,
4444
ValueFromPipelineByPropertyName = true)]
45+
#if AICLI_DISABLE_TEST_HOOKS
4546
[ValidateSet(
4647
"Microsoft.Rest",
4748
"Microsoft.PreIndexed.Package")]
49+
#else
50+
[ValidateSet(
51+
"Microsoft.Rest",
52+
"Microsoft.PreIndexed.Package",
53+
"Microsoft.Test.Configurable")]
54+
#endif
4855
public string Type { get; set; }
4956

5057
/// <summary>

src/PowerShell/tests/Microsoft.WinGet.Client.Tests.ps1

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -504,6 +504,9 @@ Describe 'Install-WinGetPackage Source Priority' {
504504
}
505505

506506
It 'Install higher Priority' {
507+
$ogSettings = @{ experimentalFeatures= @{sourcePriority=$true}}
508+
SetWinGetSettingsHelper $ogSettings
509+
507510
RemoveTestSource
508511
Add-WinGetSource -Name 'TestSource' -Arg 'https://localhost:5001/TestKit/' -Priority 1
509512
Add-WinGetSource -Name 'dummyPackageSource' -Type 'Microsoft.Test.Configurable' -Arg '{"ContainsPackage":true}'
@@ -523,14 +526,15 @@ Describe 'Install-WinGetPackage Source Priority' {
523526
}
524527

525528
AfterEach {
526-
Remove-WinGetSource -Name 'dummyPackageSource'
527-
RemoveTestSource
528-
529529
$testExe = Get-WinGetPackage -Id AppInstallerTest.TestExeInstaller -MatchOption Equals
530530
if ($testExe.Count -gt 0)
531531
{
532532
Uninstall-WinGetPackage -Id AppInstallerTest.TestExeInstaller
533533
}
534+
535+
Remove-WinGetSource -Name 'dummyPackageSource'
536+
RemoveTestSource
537+
RestoreWinGetSettings
534538
}
535539
}
536540

src/PowerShell/tests/Microsoft.WinGet.DSC.Tests.ps1

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,8 @@ Describe 'WinGetUserSettings' {
130130

131131
Describe 'WinGetSource' {
132132
BeforeAll {
133+
InvokeWinGetDSC -Name WinGetUserSettings -Method Set -Property @{ Settings = @{ experimentalFeatures = @{ sourcePriority = $true } } }
134+
133135
$testSourceName = 'TestSource'
134136
$testSourceArg = 'https://localhost:5001/TestKit/'
135137
$testSourceType = 'Microsoft.PreIndexed.Package'

0 commit comments

Comments
 (0)