From 8359effa3618ba37672a86dd69547fe3bc69a7e7 Mon Sep 17 00:00:00 2001 From: Robert Holt Date: Wed, 13 Feb 2019 13:08:59 -0800 Subject: [PATCH] Fix ubuntu date alias test --- Tests/Rules/AvoidUsingAlias.tests.ps1 | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/Tests/Rules/AvoidUsingAlias.tests.ps1 b/Tests/Rules/AvoidUsingAlias.tests.ps1 index 6552bb1ac..478646c27 100644 --- a/Tests/Rules/AvoidUsingAlias.tests.ps1 +++ b/Tests/Rules/AvoidUsingAlias.tests.ps1 @@ -101,8 +101,18 @@ Configuration MyDscConfiguration { } It "do not warn when about Get-* completed cmdlets when the command exists natively on Unix platforms" -skip:(-not ($IsLinux -or $IsMacOS)) { - $violations = Invoke-ScriptAnalyzer -IncludeRule PSAvoidUsingCmdletAliases -ExcludeRule PSUseCompatibleCommands -ScriptDefinition 'date' | Where-Object { $_.RuleName -eq $violationName } - $violations[0].Message | Should -Be '' + $nativeLinuxCommand = 'date' + $dateCommand = Get-Command $nativeLinuxCommand -CommandType Application -ErrorAction Ignore + + $violations = Invoke-ScriptAnalyzer -IncludeRule PSAvoidUsingCmdletAliases -ExcludeRule PSUseCompatibleCommands -ScriptDefinition $nativeLinuxCommand | Where-Object { $_.RuleName -eq $violationName } + + $expectedViolations = 1 + if ($dateCommand) + { + $expectedViolations = 0 + } + + $violations.Count | Should -Be $expectedViolations } } }