Skip to content

Commit 8359eff

Browse files
committed
Fix ubuntu date alias test
1 parent 0df2f60 commit 8359eff

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

Tests/Rules/AvoidUsingAlias.tests.ps1

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,8 +101,18 @@ Configuration MyDscConfiguration {
101101
}
102102

103103
It "do not warn when about Get-* completed cmdlets when the command exists natively on Unix platforms" -skip:(-not ($IsLinux -or $IsMacOS)) {
104-
$violations = Invoke-ScriptAnalyzer -IncludeRule PSAvoidUsingCmdletAliases -ExcludeRule PSUseCompatibleCommands -ScriptDefinition 'date' | Where-Object { $_.RuleName -eq $violationName }
105-
$violations[0].Message | Should -Be ''
104+
$nativeLinuxCommand = 'date'
105+
$dateCommand = Get-Command $nativeLinuxCommand -CommandType Application -ErrorAction Ignore
106+
107+
$violations = Invoke-ScriptAnalyzer -IncludeRule PSAvoidUsingCmdletAliases -ExcludeRule PSUseCompatibleCommands -ScriptDefinition $nativeLinuxCommand | Where-Object { $_.RuleName -eq $violationName }
108+
109+
$expectedViolations = 1
110+
if ($dateCommand)
111+
{
112+
$expectedViolations = 0
113+
}
114+
115+
$violations.Count | Should -Be $expectedViolations
106116
}
107117
}
108118
}

0 commit comments

Comments
 (0)