mirror of
https://github.com/tw93/Mole.git
synced 2026-03-23 18:10:07 +00:00
fix(windows): harden visual lookups in logger
This commit is contained in:
@@ -6,7 +6,7 @@ BeforeAll {
|
||||
$script:WindowsDir = Split-Path -Parent $PSScriptRoot
|
||||
$script:BinDir = Join-Path $script:WindowsDir "bin"
|
||||
$script:InstallScript = Join-Path $script:WindowsDir "install.ps1"
|
||||
$script:VisualDefaultsErrorPattern = 'property ''Solid'' cannot be found|找不到属性.?Solid|VariableIsUndefined|\$script:Colors'
|
||||
$script:VisualDefaultsErrorPattern = 'property ''(Solid|Error)'' cannot be found|找不到属性.?(Solid|Error)|VariableIsUndefined|\$script:Colors'
|
||||
}
|
||||
|
||||
Describe "Clean Command" {
|
||||
|
||||
@@ -70,6 +70,14 @@ Describe "Base Module" {
|
||||
$script:Icons.Solid | Should -Be "*"
|
||||
$script:Icons.Admin | Should -Not -BeNullOrEmpty
|
||||
}
|
||||
|
||||
It "Should restore missing icon entries on demand" {
|
||||
$script:Icons = @{ Solid = "*" }
|
||||
|
||||
(Get-MoleIcon -Name "Error") | Should -Not -BeNullOrEmpty
|
||||
$script:Icons.Error | Should -Not -BeNullOrEmpty
|
||||
$script:Icons.Solid | Should -Be "*"
|
||||
}
|
||||
}
|
||||
|
||||
Context "Test-IsAdmin" {
|
||||
@@ -242,6 +250,19 @@ Describe "Logging Module" {
|
||||
# Note: The actual function is Write-MoleError
|
||||
{ Write-MoleError "Test message" } | Should -Not -Throw
|
||||
}
|
||||
|
||||
It "Should log errors even when the icon table is partial" {
|
||||
$originalIcons = $script:Icons.Clone()
|
||||
|
||||
try {
|
||||
$script:Icons = @{ Solid = "*" }
|
||||
{ Write-MoleError "Test message" } | Should -Not -Throw
|
||||
$script:Icons.Error | Should -Not -BeNullOrEmpty
|
||||
}
|
||||
finally {
|
||||
$script:Icons = $originalIcons
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Context "Section Functions" {
|
||||
|
||||
Reference in New Issue
Block a user