Skip to content

Commit

Permalink
Fix ubuntu date alias test
Browse files Browse the repository at this point in the history
  • Loading branch information
rjmholt committed Feb 13, 2019
1 parent 0df2f60 commit 8359eff
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions Tests/Rules/AvoidUsingAlias.tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
}

0 comments on commit 8359eff

Please sign in to comment.