Bump PSDesiredStateConfiguration from 2.0.3 to 2.0.4 (#10603)

This commit is contained in:
dependabot-preview[bot]
2019-09-23 15:42:39 -07:00
committed by Travis Plunk
parent ce08b9b670
commit 83453d1e5c
3 changed files with 184 additions and 149 deletions
+1 -1
View File
@@ -8,7 +8,7 @@
<PackageReference Include="Microsoft.PowerShell.Archive" Version="1.2.3.0" />
<PackageReference Include="PSReadLine" Version="2.0.0-beta5" />
<PackageReference Include="ThreadJob" Version="2.0.1" />
<PackageReference Include="PSDesiredStateConfiguration" Version="2.0.3" />
<PackageReference Include="PSDesiredStateConfiguration" Version="2.0.4" />
</ItemGroup>
</Project>
@@ -1,8 +1,6 @@
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.
Function Install-ModuleIfMissing
{
Function Install-ModuleIfMissing {
param(
[parameter(Mandatory)]
[String]
@@ -17,50 +15,67 @@ Function Install-ModuleIfMissing
$module = Get-Module -Name $Name -ListAvailable -ErrorAction Ignore | Sort-Object -Property Version -Descending | Select-Object -First 1
if(!$module -or $module.Version -lt $MinimumVersion)
{
if (!$module -or $module.Version -lt $MinimumVersion) {
Write-Verbose "Installing module '$Name' ..." -Verbose
Install-Module -Name $Name -Force -SkipPublisherCheck:$SkipPublisherCheck.IsPresent
}
}
Function Test-IsInvokeDscResourceEnable
{
Function Test-IsInvokeDscResourceEnable {
return [ExperimentalFeature]::IsEnabled("PSDesiredStateConfiguration.InvokeDscResource")
}
Describe "Test PSDesiredStateConfiguration" -tags CI {
Context "Module loading" {
BeforeAll {
$commands = Get-Command -Module PSDesiredStateConfiguration
$expectedCommandCount = 3
if (Test-IsInvokeDscResourceEnable)
{
$expectedCommandCount ++
}
}
BeforeEach {
}
AfterEach {
}
AfterAll {
}
Function BeCommand {
[CmdletBinding()]
Param(
[object[]] $ActualValue,
[string] $CommandName,
[string] $ModuleName,
[switch]$Negate
)
It "The module should have $expectedCommandCount commands" {
if ($commands.Count -ne $expectedCommandCount)
{
$modulePath = (Get-Module PSDesiredStateConfiguration).Path
Write-Verbose -Verbose -Message "PSDesiredStateConfiguration Path: $modulePath"
$commands | Out-String | Write-Verbose -Verbose
$failure = if ($Negate) {
"Expected: Command $CommandName should not exist in module $ModuleName"
}
else {
"Expected: Command $CommandName should exist in module $ModuleName"
}
$succeeded = if ($Negate) {
($ActualValue | Where-Object { $_.Name -eq $CommandName }).count -eq 0
}
else {
($ActualValue | Where-Object { $_.Name -eq $CommandName }).count -gt 0
}
return [PSCustomObject]@{
Succeeded = $succeeded
FailureMessage = $failure
}
}
$commands.Count | Should -Be $expectedCommandCount
Add-AssertionOperator -Name 'HaveCommand' -Test $Function:BeCommand -SupportsArrayInput
$commands = Get-Command -Module PSDesiredStateConfiguration
}
It "The module should have the Configuration Command" {
$commands | Where-Object {$_.Name -eq 'Configuration'} | Should -Not -BeNullOrEmpty
$commands | Should -HaveCommand -CommandName 'Configuration' -ModuleName PSDesiredStateConfiguration
}
It "The module should have the Configuration Command" {
$commands | Should -HaveCommand -CommandName 'New-DscChecksum' -ModuleName PSDesiredStateConfiguration
}
It "The module should have the Get-DscResource Command" {
$commands | Where-Object {$_.Name -eq 'Get-DscResource'} | Should -Not -BeNullOrEmpty
$commands | Should -HaveCommand -CommandName 'Get-DscResource' -ModuleName PSDesiredStateConfiguration
}
It "The module should have the Invoke-DscResource Command" -Skip:(!(Test-IsInvokeDscResourceEnable)) {
$commands | Should -HaveCommand -CommandName 'Invoke-DscResource' -ModuleName PSDesiredStateConfiguration
}
}
Context "Get-DscResource - Composite Resources" {
@@ -71,75 +86,72 @@ Describe "Test PSDesiredStateConfiguration" -tags CI {
$testCases = @(
@{
TestCaseName = 'case mismatch in resource name'
Name = 'groupset'
ModuleName = 'PSDscResources'
Name = 'groupset'
ModuleName = 'PSDscResources'
}
@{
TestCaseName = 'Both names have matching case'
Name = 'GroupSet'
ModuleName = 'PSDscResources'
Name = 'GroupSet'
ModuleName = 'PSDscResources'
}
@{
TestCaseName = 'case mismatch in module name'
Name = 'GroupSet'
ModuleName = 'psdscResources'
Name = 'GroupSet'
ModuleName = 'psdscResources'
}
)
}
AfterAll {
$Global:ProgressPreference = $origProgress
}
it "should be able to get <Name> - <TestCaseName>" -TestCases $testCases {
param($Name)
if($IsWindows)
{
if ($IsWindows) {
Set-ItResult -Pending -Because "Will only find script from PSDesiredStateConfiguration without modulename"
}
if($IsLinux)
{
if ($IsLinux) {
Set-ItResult -Pending -Because "https://github.com/PowerShell/PSDesiredStateConfiguration/issues/26"
}
$resource = Get-DscResource -Name $name
$resource | Should -Not -BeNullOrEmpty
$resource.Name | Should -Be $Name
if (Test-IsInvokeDscResourceEnable)
{
if (Test-IsInvokeDscResourceEnable) {
$resource.ImplementationDetail | Should -BeNullOrEmpty
} else
{
}
else {
$resource.ImplementationDetail | Should -BeNullOrEmpty
}
}
it "should be able to get <Name> from <ModuleName> - <TestCaseName>" -TestCases $testCases {
param($Name,$ModuleName, $PendingBecause)
param($Name, $ModuleName, $PendingBecause)
if($IsLinux)
{
if ($IsLinux) {
Set-ItResult -Pending -Because "https://github.com/PowerShell/PSDesiredStateConfiguration/issues/26"
}
if($PendingBecause)
{
if ($PendingBecause) {
Set-ItResult -Pending -Because $PendingBecause
}
$resource = Get-DscResource -Name $Name -Module $ModuleName
$resource | Should -Not -BeNullOrEmpty
$resource.Name | Should -Be $Name
if (Test-IsInvokeDscResourceEnable)
{
if (Test-IsInvokeDscResourceEnable) {
$resource.ImplementationDetail | Should -BeNullOrEmpty
}
else
{
else {
$resource.ImplementationDetail | Should -BeNullOrEmpty
}
}
}
Context "Get-DscResource - ScriptResources" {
BeforeAll {
$origProgress = $global:ProgressPreference
@@ -147,26 +159,27 @@ Describe "Test PSDesiredStateConfiguration" -tags CI {
Install-ModuleIfMissing -Name PSDscResources -Force
# Install PowerShellGet only if PowerShellGet 2.2.1 or newer does not exist
Install-ModuleIfMissing -Name PowerShellGet -MinimumVersion '2.2.1'
$module = Get-Module PowerShellGet -ListAvailable | Sort-Object -Property Version -Descending | Select-Object -First 1
$psGetModuleSpecification = @{ModuleName=$module.Name;ModuleVersion=$module.Version.ToString()}
$psGetModuleSpecification = @{ModuleName = $module.Name; ModuleVersion = $module.Version.ToString() }
$psGetModuleCount = @(Get-Module PowerShellGet -ListAvailable).Count
$testCases = @(
@{
TestCaseName = 'case mismatch in resource name'
Name = 'script'
ModuleName = 'PSDscResources'
Name = 'script'
ModuleName = 'PSDscResources'
}
@{
TestCaseName = 'Both names have matching case'
Name = 'Script'
ModuleName = 'PSDscResources'
Name = 'Script'
ModuleName = 'PSDscResources'
}
@{
TestCaseName = 'case mismatch in module name'
Name = 'Script'
ModuleName = 'psdscResources'
Name = 'Script'
ModuleName = 'psdscResources'
}
<#
Add these back when PowerShellGet is fixed https://github.com/PowerShell/PowerShellGet/pull/529
@@ -188,6 +201,7 @@ Describe "Test PSDesiredStateConfiguration" -tags CI {
#>
)
}
AfterAll {
$Global:ProgressPreference = $origProgress
}
@@ -195,27 +209,22 @@ Describe "Test PSDesiredStateConfiguration" -tags CI {
it "should be able to get <Name> - <TestCaseName>" -TestCases $testCases {
param($Name)
if($IsWindows)
{
if ($IsWindows) {
Set-ItResult -Pending -Because "Will only find script from PSDesiredStateConfiguration without modulename"
}
if($PendingBecause)
{
if ($PendingBecause) {
Set-ItResult -Pending -Because $PendingBecause
}
$resources = @(Get-DscResource -Name $name)
$resources | Should -Not -BeNullOrEmpty
foreach($resource in $resource)
{
foreach ($resource in $resource) {
$resource.Name | Should -Be $Name
if (Test-IsInvokeDscResourceEnable)
{
if (Test-IsInvokeDscResourceEnable) {
$resource.ImplementationDetail | Should -Be 'ScriptBased'
}
else
{
else {
$resource.ImplementationDetail | Should -BeNullOrEmpty
}
@@ -223,29 +232,24 @@ Describe "Test PSDesiredStateConfiguration" -tags CI {
}
it "should be able to get <Name> from <ModuleName> - <TestCaseName>" -TestCases $testCases {
param($Name,$ModuleName, $PendingBecause)
param($Name, $ModuleName, $PendingBecause)
if($IsLinux)
{
if ($IsLinux) {
Set-ItResult -Pending -Because "https://github.com/PowerShell/PSDesiredStateConfiguration/issues/12 and https://github.com/PowerShell/PowerShellGet/pull/529"
}
if($PendingBecause)
{
if ($PendingBecause) {
Set-ItResult -Pending -Because $PendingBecause
}
$resources = @(Get-DscResource -Name $name -Module $ModuleName)
$resources | Should -Not -BeNullOrEmpty
foreach($resource in $resource)
{
foreach ($resource in $resource) {
$resource.Name | Should -Be $Name
if (Test-IsInvokeDscResourceEnable)
{
if (Test-IsInvokeDscResourceEnable) {
$resource.ImplementationDetail | Should -Be 'ScriptBased'
}
else
{
else {
$resource.ImplementationDetail | Should -BeNullOrEmpty
}
}
@@ -256,7 +260,7 @@ Describe "Test PSDesiredStateConfiguration" -tags CI {
{
Get-DscResource -Name antoehusatnoheusntahoesnuthao -Module tanshoeusnthaosnetuhasntoheusnathoseun
} |
Should -Throw -ErrorId 'Microsoft.PowerShell.Commands.WriteErrorException,CheckResourceFound'
Should -Throw -ErrorId 'Microsoft.PowerShell.Commands.WriteErrorException,CheckResourceFound'
}
}
Context "Get-DscResource - Class base Resources" {
@@ -268,65 +272,61 @@ Describe "Test PSDesiredStateConfiguration" -tags CI {
$classTestCases = @(
@{
TestCaseName = 'Good case'
Name = 'XmlFileContentResource'
ModuleName = 'XmlContentDsc'
Name = 'XmlFileContentResource'
ModuleName = 'XmlContentDsc'
}
@{
TestCaseName = 'Module Name case mismatch'
Name = 'XmlFileContentResource'
ModuleName = 'xmlcontentdsc'
Name = 'XmlFileContentResource'
ModuleName = 'xmlcontentdsc'
}
@{
TestCaseName = 'Resource name case mismatch'
Name = 'xmlfilecontentresource'
ModuleName = 'XmlContentDsc'
Name = 'xmlfilecontentresource'
ModuleName = 'XmlContentDsc'
}
)
}
AfterAll {
$Global:ProgressPreference = $origProgress
$global:ProgressPreference = $origProgress
}
it "should be able to get class resource - <Name> from <ModuleName> - <TestCaseName>" -TestCases $classTestCases {
param($Name,$ModuleName, $PendingBecause)
param($Name, $ModuleName, $PendingBecause)
if($PendingBecause)
{
if ($PendingBecause) {
Set-ItResult -Pending -Because $PendingBecause
}
$resource = Get-DscResource -Name $Name -Module $ModuleName
$resource | Should -Not -BeNullOrEmpty
$resource.Name | Should -Be $Name
if (Test-IsInvokeDscResourceEnable)
{
if (Test-IsInvokeDscResourceEnable) {
$resource.ImplementationDetail | Should -Be 'ClassBased'
}
else
{
else {
$resource.ImplementationDetail | Should -BeNullOrEmpty
}
}
it "should be able to get class resource - <Name> - <TestCaseName>" -TestCases $classTestCases {
param($Name,$ModuleName, $PendingBecause)
if($IsWindows)
{
param($Name, $ModuleName, $PendingBecause)
if ($IsWindows) {
Set-ItResult -Pending -Because "https://github.com/PowerShell/PSDesiredStateConfiguration/issues/19"
}
if($PendingBecause)
{
if ($PendingBecause) {
Set-ItResult -Pending -Because $PendingBecause
}
$resource = Get-DscResource -Name $Name
$resource | Should -Not -BeNullOrEmpty
$resource.Name | Should -Be $Name
if (Test-IsInvokeDscResourceEnable)
{
if (Test-IsInvokeDscResourceEnable) {
$resource.ImplementationDetail | Should -Be 'ClassBased'
}
else
{
else {
$resource.ImplementationDetail | Should -BeNullOrEmpty
}
}
@@ -336,51 +336,51 @@ Describe "Test PSDesiredStateConfiguration" -tags CI {
$origProgress = $global:ProgressPreference
$global:ProgressPreference = 'SilentlyContinue'
$module = Get-InstalledModule -Name PsDscResources -ErrorAction Ignore
if($module)
{
if ($module) {
Write-Verbose "removing PSDscResources, tests will re-install..." -Verbose
Uninstall-Module -Name PsDscResources -AllVersions -Force
}
}
AfterAll {
$Global:ProgressPreference = $origProgress
}
Context "mof resources" {
Context "mof resources" {
BeforeAll {
$dscMachineStatusCases = @(
@{
value = '1'
value = '1'
expectedResult = $true
}
@{
value = '$true'
value = '$true'
expectedResult = $true
}
@{
value = '0'
value = '0'
expectedResult = $false
}
@{
value = '$false'
value = '$false'
expectedResult = $false
}
)
Install-ModuleIfMissing -Name PowerShellGet -Force -SkipPublisherCheck -MinimumVersion '2.2.1'
Install-ModuleIfMissing -Name xWebAdministration
$module = Get-Module PowerShellGet -ListAvailable | Sort-Object -Property Version -Descending | Select-Object -First 1
$psGetModuleSpecification = @{ModuleName=$module.Name;ModuleVersion=$module.Version.ToString()}
$psGetModuleSpecification = @{ModuleName = $module.Name; ModuleVersion = $module.Version.ToString() }
}
it "Set method should work" -Skip:(!(Test-IsInvokeDscResourceEnable)) {
if(!$IsLinux)
{
$result = Invoke-DscResource -Name PSModule -ModuleName $psGetModuleSpecification -Method set -Property @{
Name = 'PsDscResources'
if (!$IsLinux) {
$result = Invoke-DscResource -Name PSModule -ModuleName $psGetModuleSpecification -Method set -Property @{
Name = 'PsDscResources'
InstallationPolicy = 'Trusted'
}
}
else
{
else {
# workraound because of https://github.com/PowerShell/PowerShellGet/pull/529
Install-ModuleIfMissing -Name PsDscResources -Force
}
@@ -397,62 +397,92 @@ Describe "Test PSDesiredStateConfiguration" -tags CI {
# using create scriptBlock because $using:<variable> doesn't work with existing Invoke-DscResource
# Verified in Windows PowerShell on 20190814
$result = Invoke-DscResource -Name Script -ModuleName PSDscResources -Method Set -Property @{TestScript = {Write-Output 'test';return $false};GetScript = {return @{}}; SetScript = [scriptblock]::Create("`$global:DSCMachineStatus = $value;return")}
$result = Invoke-DscResource -Name Script -ModuleName PSDscResources -Method Set -Property @{TestScript = { Write-Output 'test'; return $false }; GetScript = { return @{ } }; SetScript = [scriptblock]::Create("`$global:DSCMachineStatus = $value;return") }
$result | Should -Not -BeNullOrEmpty
$result.RebootRequired | Should -BeExactly $expectedResult
}
it "Test method should return false" -Skip:(!(Test-IsInvokeDscResourceEnable)) {
$result = Invoke-DscResource -Name Script -ModuleName PSDscResources -Method Test -Property @{TestScript = {Write-Output 'test';return $false};GetScript = {return @{}}; SetScript = {return}}
it "Test method should return false" -Skip:(!(Test-IsInvokeDscResourceEnable)) {
$result = Invoke-DscResource -Name Script -ModuleName PSDscResources -Method Test -Property @{TestScript = { Write-Output 'test'; return $false }; GetScript = { return @{ } }; SetScript = { return } }
$result | Should -Not -BeNullOrEmpty
$result.InDesiredState | Should -BeFalse -Because "Test method return false"
}
it "Test method should return true" -Skip:(!(Test-IsInvokeDscResourceEnable)) {
$result = Invoke-DscResource -Name Script -ModuleName PSDscResources -Method Test -Property @{TestScript = {Write-Verbose 'test';return $true};GetScript = {return @{}}; SetScript = {return}}
$result | Should -BeTrue -Because "Test method return true"
}
it "Test method should return true with moduleSpecification" -Skip:(!(Test-IsInvokeDscResourceEnable)) {
$module = get-module PsDscResources -ListAvailable
$moduleSpecification = @{ModuleName=$module.Name;ModuleVersion=$module.Version.ToString()}
$result = Invoke-DscResource -Name Script -ModuleName $moduleSpecification -Method Test -Property @{TestScript = {Write-Verbose 'test';return $true};GetScript = {return @{}}; SetScript = {return}}
it "Test method should return true" -Skip:(!(Test-IsInvokeDscResourceEnable)) {
$result = Invoke-DscResource -Name Script -ModuleName PSDscResources -Method Test -Property @{TestScript = { Write-Verbose 'test'; return $true }; GetScript = { return @{ } }; SetScript = { return } }
$result | Should -BeTrue -Because "Test method return true"
}
it "Invalid moduleSpecification" -Skip:(!(Test-IsInvokeDscResourceEnable)) {
it "Test method should return true with moduleSpecification" -Skip:(!(Test-IsInvokeDscResourceEnable)) {
$module = get-module PsDscResources -ListAvailable
$moduleSpecification = @{ModuleName = $module.Name; ModuleVersion = $module.Version.ToString() }
$result = Invoke-DscResource -Name Script -ModuleName $moduleSpecification -Method Test -Property @{TestScript = { Write-Verbose 'test'; return $true }; GetScript = { return @{ } }; SetScript = { return } }
$result | Should -BeTrue -Because "Test method return true"
}
it "Invalid moduleSpecification" -Skip:(!(Test-IsInvokeDscResourceEnable)) {
Set-ItResult -Pending -Because "https://github.com/PowerShell/PSDesiredStateConfiguration/issues/17"
$moduleSpecification = @{ModuleName='PsDscResources';ModuleVersion='99.99.99.993'}
$moduleSpecification = @{ModuleName = 'PsDscResources'; ModuleVersion = '99.99.99.993' }
{
Invoke-DscResource -Name Script -ModuleName $moduleSpecification -Method Test -Property @{TestScript = {Write-Host 'test';return $true};GetScript = {return @{}}; SetScript = {return}} -ErrorAction Stop
Invoke-DscResource -Name Script -ModuleName $moduleSpecification -Method Test -Property @{TestScript = { Write-Host 'test'; return $true }; GetScript = { return @{ } }; SetScript = { return } } -ErrorAction Stop
} |
Should -Throw -ErrorId 'InvalidResourceSpecification,Invoke-DscResource' -ExpectedMessage 'Invalid Resource Name ''Script'' or module specification.'
Should -Throw -ErrorId 'InvalidResourceSpecification,Invoke-DscResource' -ExpectedMessage 'Invalid Resource Name ''Script'' or module specification.'
}
it "Resource with embedded resource not supported and a warning should be produced" {
if (!(Test-IsInvokeDscResourceEnable)) {
Set-ItResult -Skipped -Because "Feature not enabled"
}
if (!$IsMacOS) {
Set-ItResult -Skipped -Because "Not applicable on Windows and xWebAdministration resources don't load on linux"
}
try {
Invoke-DscResource -Name xWebSite -ModuleName 'xWebAdministration' -Method Test -Property @{TestScript = 'foobar' } -ErrorAction Stop -WarningVariable warnings
}
catch{
#this will fail too, but that is nat what we are testing...
}
$warnings.Count | Should -Be 1 -because "There should be 1 warning on macOS and Linux"
$warnings[0] | Should -Match 'embedded resources.*not support'
}
it "Using PsDscRunAsCredential should say not supported" -Skip:(!(Test-IsInvokeDscResourceEnable)) {
{
Invoke-DscResource -Name Script -ModuleName PSDscResources -Method Set -Property @{TestScript = { Write-Output 'test'; return $false }; GetScript = { return @{ } }; SetScript = {return}; PsDscRunAsCredential='natoheu'} -ErrorAction Stop
} |
Should -Throw -ErrorId 'PsDscRunAsCredentialNotSupport,Invoke-DscResource'
}
# waiting on Get-DscResource to be fixed
it "Invalid module name" -Skip:(!(Test-IsInvokeDscResourceEnable)) {
it "Invalid module name" -Skip:(!(Test-IsInvokeDscResourceEnable)) {
Set-ItResult -Pending -Because "https://github.com/PowerShell/PSDesiredStateConfiguration/issues/17"
{
Invoke-DscResource -Name Script -ModuleName santoheusnaasonteuhsantoheu -Method Test -Property @{TestScript = {Write-Host 'test';return $true};GetScript = {return @{}}; SetScript = {return}} -ErrorAction Stop
Invoke-DscResource -Name Script -ModuleName santoheusnaasonteuhsantoheu -Method Test -Property @{TestScript = { Write-Host 'test'; return $true }; GetScript = { return @{ } }; SetScript = { return } } -ErrorAction Stop
} |
Should -Throw -ErrorId 'Microsoft.PowerShell.Commands.WriteErrorException,CheckResourceFound'
Should -Throw -ErrorId 'Microsoft.PowerShell.Commands.WriteErrorException,CheckResourceFound'
}
it "Invalid resource name" -Skip:(!(Test-IsInvokeDscResourceEnable)) {
it "Invalid resource name" -Skip:(!(Test-IsInvokeDscResourceEnable)) {
if ($IsWindows) {
Set-ItResult -Pending -Because "https://github.com/PowerShell/PSDesiredStateConfiguration/issues/17"
}
{
Invoke-DscResource -Name santoheusnaasonteuhsantoheu -Method Test -Property @{TestScript = {Write-Host 'test';return $true};GetScript = {return @{}}; SetScript = {return}} -ErrorAction Stop
Invoke-DscResource -Name santoheusnaasonteuhsantoheu -Method Test -Property @{TestScript = { Write-Host 'test'; return $true }; GetScript = { return @{ } }; SetScript = { return } } -ErrorAction Stop
} |
Should -Throw -ErrorId 'Microsoft.PowerShell.Commands.WriteErrorException,CheckResourceFound'
Should -Throw -ErrorId 'Microsoft.PowerShell.Commands.WriteErrorException,CheckResourceFound'
}
it "Get method should work" -Skip:(!(Test-IsInvokeDscResourceEnable)) {
if($IsLinux)
{
it "Get method should work" -Skip:(!(Test-IsInvokeDscResourceEnable)) {
if ($IsLinux) {
Set-ItResult -Pending -Because "https://github.com/PowerShell/PSDesiredStateConfiguration/issues/12 and https://github.com/PowerShell/PowerShellGet/pull/529"
}
$result = Invoke-DscResource -Name PSModule -ModuleName $psGetModuleSpecification -Method Get -Property @{ Name = 'PsDscResources'}
$result = Invoke-DscResource -Name PSModule -ModuleName $psGetModuleSpecification -Method Get -Property @{ Name = 'PsDscResources' }
$result | Should -Not -BeNullOrEmpty
$result.Author | Should -BeLike 'Microsoft*'
$result.InstallationPolicy | Should -BeOfType [string]
@@ -466,13 +496,16 @@ Describe "Test PSDesiredStateConfiguration" -tags CI {
$result.ModuleType | Should -Be 'Manifest'
}
}
Context "Class Based Resources" {
BeforeAll {
Install-ModuleIfMissing -Name XmlContentDsc -Force
}
AfterAll {
$Global:ProgressPreference = $origProgress
}
BeforeEach {
$testXmlPath = 'TestDrive:\test.xml'
@'
@@ -484,14 +517,15 @@ Describe "Test PSDesiredStateConfiguration" -tags CI {
'@ | Out-File -FilePath $testXmlPath -Encoding utf8NoBOM
$resolvedXmlPath = (Resolve-Path -Path $testXmlPath).ProviderPath
}
it 'Set method should work' -Skip:(!(Test-IsInvokeDscResourceEnable)) {
it 'Set method should work' -Skip:(!(Test-IsInvokeDscResourceEnable)) {
param(
$value,
$ExpectedResult
)
$testString = '890574209347509120348'
$result = Invoke-DscResource -Name XmlFileContentResource -ModuleName XmlContentDsc -Property @{Path=$resolvedXmlPath; XPath = '/configuration/appSetting/Test1';Ensure='Present'; Attributes=@{ TestValue2 = $testString; Name = $testString } } -Method Set
$result = Invoke-DscResource -Name XmlFileContentResource -ModuleName XmlContentDsc -Property @{Path = $resolvedXmlPath; XPath = '/configuration/appSetting/Test1'; Ensure = 'Present'; Attributes = @{ TestValue2 = $testString; Name = $testString } } -Method Set
$result | Should -Not -BeNullOrEmpty
$result.RebootRequired | Should -BeFalse
$testXmlPath | Should -FileContentMatch $testString
@@ -499,4 +533,3 @@ Describe "Test PSDesiredStateConfiguration" -tags CI {
}
}
}
@@ -1,12 +1,14 @@
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.
Describe "DSC MOF Compilation" -tags "CI" {
BeforeAll {
Import-module PSDesiredStateConfiguration
$module = Get-Module PowerShellGet -ListAvailable | Sort-Object -Property Version -Descending | Select-Object -First 1
$psGetModuleVersion = $module.Version.ToString()
if (!$env:DSC_HOME)
{
Import-Module PSDesiredStateConfiguration
}
}
It "Should be able to compile a MOF using PSModule resource" {