-
Notifications
You must be signed in to change notification settings - Fork 0
/
Reset-ModuleInProfile.Tests.ps1
31 lines (24 loc) · 1.09 KB
/
Reset-ModuleInProfile.Tests.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
using module ..\.\TestRunnerSupportModule.psm1
Describe "Test Reset-ModuleInProfile" {
BeforeAll {
$TestSupportModule = [TestRunnerSupportModule]::new('MockModuleA')
$MockProfilePath = Join-Path -Path ($TestSupportModule.TestDrivePath) -ChildPath "\User\Bob\Documents\PowerShell\" -AdditionalChildPath "MK.PowerShell-profile.ps1"
New-Item -Path $MockProfilePath -ItemType File -Force | Select-Object -ExpandProperty FullName
}
AfterAll {
$TestSupportModule.Teardown()
}
Context "Resetting import module in profile" {
It "Should reset Import-Module statement in profile" {
$MockProfileContent = @"
Import-Module C:\Users\Bob\Foo
# Import-Module C:\Users\Bob\Plaster
Import-Module C:\Users\Bob\Goo
"@
Set-Content -Path $MockProfilePath -Value $MockProfileContent
Reset-ModuleInProfile -Name 'Plaster' -ProfilePath $MockProfilePath
$Results = Get-Content -Path $MockProfilePath
$Results[1] | Should -eq 'Import-Module C:\Users\Bob\Plaster'
}
}
}