Skip to content

Commit 5705b00

Browse files
committed
Add testcases for all users profile
Signed-off-by: Dominik Viererbe <dominik.viererbe@canonical.com>
1 parent 4a09304 commit 5705b00

File tree

1 file changed

+27
-10
lines changed

1 file changed

+27
-10
lines changed

test/powershell/Host/Base-Directory.Tests.ps1

Lines changed: 27 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,23 @@ Describe "Configuration file locations" -tags "CI","Slow" {
1717
{
1818
$ProductName = "PowerShell"
1919
}
20-
$expectedCache = [IO.Path]::Combine($env:LOCALAPPDATA, "Microsoft", "Windows", "PowerShell", "StartupProfileData-NonInteractive")
21-
$expectedModule = [IO.Path]::Combine($env:USERPROFILE, "Documents", $ProductName, "Modules")
22-
$expectedProfile = [IO.Path]::Combine($env:USERPROFILE, "Documents", $ProductName, $profileName)
23-
$expectedReadline = [IO.Path]::Combine($env:AppData, "Microsoft", "Windows", "PowerShell", "PSReadline", "ConsoleHost_history.txt")
20+
$expectedCache = [IO.Path]::Combine($env:LOCALAPPDATA, "Microsoft", "Windows", "PowerShell", "StartupProfileData-NonInteractive")
21+
$expectedModule = [IO.Path]::Combine($env:USERPROFILE, "Documents", $ProductName, "Modules")
22+
$expectedAllUsersProfile = [IO.Path]::Combine($PSHOME, $profileName)
23+
$expectedCurrentUserProfile = [IO.Path]::Combine($env:USERPROFILE, "Documents", $ProductName, $profileName)
24+
$expectedReadline = [IO.Path]::Combine($env:AppData, "Microsoft", "Windows", "PowerShell", "PSReadline", "ConsoleHost_history.txt")
2425
} else {
25-
$expectedCache = [IO.Path]::Combine($env:HOME, ".cache", "powershell", "StartupProfileData-NonInteractive")
26-
$expectedModule = [IO.Path]::Combine($env:HOME, ".local", "share", "powershell", "Modules")
27-
$expectedProfile = [IO.Path]::Combine($env:HOME,".config","powershell",$profileName)
28-
$expectedReadline = [IO.Path]::Combine($env:HOME, ".local", "share", "powershell", "PSReadLine", "ConsoleHost_history.txt")
26+
if ($IsMacOS) {
27+
$PowershellConfigRoot = "/Library/Application Support/PowerShell"
28+
} else {
29+
$PowershellConfigRoot = "/etc/opt/powershell"
30+
}
31+
32+
$expectedCache = [IO.Path]::Combine($env:HOME, ".cache", "powershell", "StartupProfileData-NonInteractive")
33+
$expectedModule = [IO.Path]::Combine($env:HOME, ".local", "share", "powershell", "Modules")
34+
$expectedAllUsersProfile = [IO.Path]::Combine($PowershellConfigRoot, $profileName)
35+
$expectedCurrentUserProfile = [IO.Path]::Combine($env:HOME,".config","powershell", $profileName)
36+
$expectedReadline = [IO.Path]::Combine($env:HOME, ".local", "share", "powershell", "PSReadLine", "ConsoleHost_history.txt")
2937
}
3038

3139
$ItArgs = @{}
@@ -39,8 +47,17 @@ Describe "Configuration file locations" -tags "CI","Slow" {
3947
$env:PSModulePath = $original_PSModulePath
4048
}
4149

42-
It @ItArgs "Profile location should be correct" {
43-
& $powershell -noprofile -c `$PROFILE | Should -Be $expectedProfile
50+
It @ItArgs "Current User Profile location should be correct" {
51+
& $powershell -noprofile -c `$PROFILE | Should -Be $expectedCurrentUserProfile
52+
}
53+
54+
It @ItArgs "All Users Profile location should be correct" {
55+
& $powershell -noprofile -c `$PROFILE.AllUsersAllHosts | Should -Be $expectedAllUsersProfile
56+
}
57+
58+
It @ItArgs "All Users Profile location should be correct" {
59+
$env:POWERSHELL_COMMON_APPLICATION_DATA = Join-Path -Path $PSHOME -ChildPath $profileName
60+
& $powershell -noprofile -c `$PROFILE.AllUsersAllHosts | Should -Be $env:POWERSHELL_COMMON_APPLICATION_DATA
4461
}
4562

4663
It @ItArgs "PSModulePath should contain the correct path" {

0 commit comments

Comments
 (0)