-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGet-DevSetupModuleInstallPath.Tests.ps1
More file actions
62 lines (55 loc) · 2.8 KB
/
Get-DevSetupModuleInstallPath.Tests.ps1
File metadata and controls
62 lines (55 loc) · 2.8 KB
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
BeforeAll {
. $PSScriptRoot\Get-DevSetupModuleInstallPath.ps1
. $PSScriptRoot\..\Providers\Powershell\Get-PowershellModuleScopeMap.ps1
. $PSScriptRoot\..\Utils\Write-StatusMessage.ps1
}
Describe "Get-DevSetupModuleInstallPath" {
Context "When DevSetup module is installed in CurrentUser scope" {
It "Should return the correct path" {
$CurrentUserPath = (Join-Path (Join-Path (Join-Path $TestDrive "Documents" ) "PowerShell" ) "Modules")
$AllUsersPath = (Join-Path (Join-Path (Join-Path $TestDrive "ProgramFiles" ) "PowerShell" ) "Modules")
Mock Get-PowershellModuleScopeMap {
return @(
@{ Scope = "CurrentUser"; Path = $CurrentUserPath },
@{ Scope = "AllUsers"; Path = $AllUsersPath }
)
}
$expectedPath = Join-Path -Path $CurrentUserPath -ChildPath "DevSetup"
Mock Test-Path { return $true } -ParameterFilter { $Path -eq $expectedPath }
$result = Get-DevSetupModuleInstallPath
$result | Should -Be $expectedPath
}
}
Context "When DevSetup module is installed in AllUsers scope" {
It "Should return the correct path" {
$CurrentUserPath = (Join-Path (Join-Path (Join-Path $TestDrive "Documents" ) "PowerShell" ) "Modules")
$AllUsersPath = (Join-Path (Join-Path (Join-Path $TestDrive "ProgramFiles" ) "PowerShell" ) "Modules")
Mock Get-PowershellModuleScopeMap {
return @(
@{ Scope = "CurrentUser"; Path = $CurrentUserPath },
@{ Scope = "AllUsers"; Path = $AllUsersPath }
)
}
$expectedPath = Join-Path -Path $AllUsersPath -ChildPath "DevSetup"
Mock Test-Path { return $true } -ParameterFilter { $Path -eq $expectedPath }
$result = Get-DevSetupModuleInstallPath
$result | Should -Be $expectedPath
}
}
Context "When DevSetup module is not installed" {
It "Should return the first scope path if module is not found" {
$CurrentUserPath = (Join-Path (Join-Path (Join-Path $TestDrive "Documents" ) "PowerShell" ) "Modules")
$AllUsersPath = (Join-Path (Join-Path (Join-Path $TestDrive "ProgramFiles" ) "PowerShell" ) "Modules")
Mock Get-PowershellModuleScopeMap {
return @(
@{ Scope = "CurrentUser"; Path = $CurrentUserPath },
@{ Scope = "AllUsers"; Path = $AllUsersPath }
)
}
Mock Test-Path { return $false }
$expectedPath = Join-Path -Path $CurrentUserPath -ChildPath "DevSetup"
$result = Get-DevSetupModuleInstallPath
$result | Should -Be $expectedPath
}
}
}