diff --git a/tests/Update-AUPackages.Tests.ps1 b/tests/Update-AUPackages.Tests.ps1 index a68a08ef..8cd004a4 100644 --- a/tests/Update-AUPackages.Tests.ps1 +++ b/tests/Update-AUPackages.Tests.ps1 @@ -4,23 +4,25 @@ import-module $PSScriptRoot\..\AU Describe 'Update-AUPackages' -Tag updateall { $saved_pwd = $pwd - function global:nuspec_file() { [xml](gc $PSScriptRoot/test_package/test_package.nuspec) } - $pkg_no = 3 + $pkg_no = 5 BeforeEach { + $stream_no = 0 $global:au_Root = "TestDrive:\packages" $global:au_NoPlugins = $true rm -Recurse $global:au_root -ea ignore foreach ( $i in 1..$pkg_no ) { - $name = "test_package_$i" + $base = if ($i -le 3) {$stream_no++; 'test_package'} else {$stream_no += 3; 'test_package_with_streams'} + $name = "${base}_$i" $path = "$au_root\$name" - cp -Recurse -Force $PSScriptRoot\test_package $path - $nu = nuspec_file + cp -Recurse -Force "$PSScriptRoot\$base" $path + $nu = [xml](gc "$PSScriptRoot\$base\$base.nuspec") $nu.package.metadata.id = $name rm "$au_root\$name\*.nuspec" $nu.OuterXml | sc "$path\$name.nuspec" + if (Test-Path "$path\$base.json") { mv "$path\$base.json" "$path\$name.json" } $module_path = Resolve-Path $PSScriptRoot\..\AU "import-module '$module_path' -Force", (gc $path\update.ps1 -ea ignore) | sc $path\update.ps1 @@ -138,7 +140,7 @@ Describe 'Update-AUPackages' -Tag updateall { } } - It 'should update package with checsum verification mode' { + It 'should update package with checksum verification mode' { $choco_path = gcm choco.exe | % Source $choco_hash = Get-FileHash $choco_path -Algorithm SHA256 | % Hash @@ -178,7 +180,7 @@ Describe 'Update-AUPackages' -Tag updateall { lsau | measure | % Count | Should Be $pkg_no $res.Count | Should Be $pkg_no - ($res.Result -match 'No new version found').Count | Should Be $pkg_no + ($res.Result -match 'No new version found').Count | Should Be $stream_no ($res | ? Updated).Count | Should Be 0 } diff --git a/tests/test_package_with_streams/test_package_with_streams.json b/tests/test_package_with_streams/test_package_with_streams.json new file mode 100644 index 00000000..2bd739d0 --- /dev/null +++ b/tests/test_package_with_streams/test_package_with_streams.json @@ -0,0 +1,5 @@ +{ + "1.2": "1.2.3", + "1.3": "1.3.1", + "1.4": "1.4-beta1" +} diff --git a/tests/test_package_with_streams/test_package_with_streams.nuspec b/tests/test_package_with_streams/test_package_with_streams.nuspec new file mode 100644 index 00000000..87eb8634 --- /dev/null +++ b/tests/test_package_with_streams/test_package_with_streams.nuspec @@ -0,0 +1,23 @@ + + + + test_package_with_streams + 1.2.3 + Test Package with Streams + Miodrag Milić + Miodrag Milić + http://www.gnu.org/copyleft/gpl.html + https://github.com/majkinetor/au + false + This is a test package with streams for Pester + This is a test package with streams for Pester + test streams pester + + + + None + + + + + diff --git a/tests/test_package_with_streams/tools/chocolateyInstall.ps1 b/tests/test_package_with_streams/tools/chocolateyInstall.ps1 new file mode 100644 index 00000000..f80c3115 --- /dev/null +++ b/tests/test_package_with_streams/tools/chocolateyInstall.ps1 @@ -0,0 +1,12 @@ +$ErrorActionPreference = 'Stop' + +$packageName = 'test_package_with_streams' +$url32 = gcm choco.exe | % Source +$checksum32 = '' + +$params = @{ + packageName = $packageName + fileFullPath = "$PSScriptRoot\choco.exe" + Url = "file:///$url32" +} +Get-ChocolateyWebFile @params diff --git a/tests/test_package_with_streams/update.ps1 b/tests/test_package_with_streams/update.ps1 new file mode 100644 index 00000000..f59df342 --- /dev/null +++ b/tests/test_package_with_streams/update.ps1 @@ -0,0 +1,13 @@ +function global:au_SearchReplace() { + @{} +} + +function global:au_GetLatest() { + @{ Streams = @{ + '1.4' = @{ Version = '1.4-beta1' } + '1.2' = @{ Version = '1.2.3' } + '1.3' = @{ Version = '1.3.1' } + } } +} + +update