From eb31aa91c10c27ee30585b56a8eaa1472e25152b Mon Sep 17 00:00:00 2001 From: Travis Plunk Date: Fri, 9 Aug 2019 12:10:49 -0700 Subject: [PATCH] Add negative get-dscresource test (#16) --- src/.ci/test.yml | 4 ++++ test/PSDesiredStateConfiguration.Tests.ps1 | 7 +++++++ 2 files changed, 11 insertions(+) diff --git a/src/.ci/test.yml b/src/.ci/test.yml index 0c5daf7..72f8542 100644 --- a/src/.ci/test.yml +++ b/src/.ci/test.yml @@ -89,12 +89,16 @@ jobs: - ${{ parameters.powershellExecutable }}: | Invoke-PSPackageProjectTest -Type Functional displayName: Execute functional tests + errorActionPreference: continue - ${{ parameters.powershellExecutable }}: | Invoke-PSPackageProjectTest -Type StaticAnalysis displayName: Execute static analysis tests + errorActionPreference: continue + condition: succeededOrFailed() - ${{ parameters.powershellExecutable }}: | Unregister-PSRepository -Name 'pspackageproject-local-repo' -ErrorAction Ignore displayName: Unregister temporary PSRepository + condition: always() diff --git a/test/PSDesiredStateConfiguration.Tests.ps1 b/test/PSDesiredStateConfiguration.Tests.ps1 index 608bf93..7404157 100644 --- a/test/PSDesiredStateConfiguration.Tests.ps1 +++ b/test/PSDesiredStateConfiguration.Tests.ps1 @@ -67,5 +67,12 @@ Describe "Test PSDesiredStateConfiguration" -tags CI { $resource = Get-DscResource -Name $Name -Module $ModuleName $resource | Should -Not -BeNullOrEmpty } + # Fails on on platforms + it "should throw when resource is not found" -Pending { + { + Get-DscResource -Name antoehusatnoheusntahoesnuthao -Module tanshoeusnthaosnetuhasntoheusnathoseun + } | + Should -Throw -ErrorId 'Microsoft.PowerShell.Commands.WriteErrorException,CheckResourceFound' + } } }