Ensure assemblies listed FileList are not loaded (#12968)

Co-authored-by: Aditya Patwardhan <Aditya Patwardhan>
This commit is contained in:
Aditya Patwardhan
2020-06-30 10:16:13 -07:00
committed by GitHub
co-authored by Aditya Patwardhan
parent 0c8aa53a90
commit 808bf22d2f
2 changed files with 39 additions and 5 deletions
@@ -361,3 +361,36 @@ Describe "Import-Module -Force behaviour" -Tag "CI" {
{ Test-Two } | Should -Throw -ErrorId 'CommandNotFoundException'
}
}
Describe "Module with FileList" -Tag "CI" {
BeforeAll {
$src = @"
using System;
namespace ModuleCmdlets
{
public class FileListLoad
{
}
}
"@
$originalPSModulePath = $env:PSModulePath
New-Item -ItemType Directory -Path "$testdrive\Modules\FileListLoadTest\" -Force > $null
$asmPath = "$TESTDRIVE\Modules\FileListLoadTest\FileListLoadTest.dll"
Add-Type -TypeDefinition $src -OutputAssembly $asmPath
$env:PSModulePath += [System.IO.Path]::PathSeparator + "$testdrive\Modules"
New-ModuleManifest -Path "$testdrive\Modules\FileListLoadTest\FileListLoadTest.psd1" -FileList @("FileListLoadTest.dll")
}
AfterAll {
$env:PSModulePath = $originalPSModulePath
}
It "Assemblies in FileList are not loaded" {
Import-Module FileListLoadTest
$asms = [System.AppDomain]::CurrentDomain.GetAssemblies().Location
$asmPath | Should -Not -BeIn $asms
}
}