Add tests for Dsc configuration compilation on Windows (#5011)

This commit is contained in:
Indhu Sivaramakrishnan 2017-10-11 10:49:35 -07:00 committed by Travis Plunk
parent f6864c3def
commit 2a9cd7211f

View file

@ -3,6 +3,7 @@ Describe "DSC MOF Compilation" -tags "CI" {
AfterAll {
$env:PSModulePath = $_modulePath
}
BeforeAll {
$env:DSC_HOME = Join-Path -Path (Join-Path -Path $PSScriptRoot -ChildPath assets) -ChildPath dsc
$_modulePath = $env:PSModulePath
@ -23,10 +24,10 @@ Describe "DSC MOF Compilation" -tags "CI" {
}
}
DSCTestConfig
"@).Invoke()
DSCTestConfig -OutputPath TestDrive:\DscTestConfig1
"@) | should not throw
Remove-Item -Force -Recurse -Path DSCTestConfig
"TestDrive:\DscTestConfig1\localhost.mof" | Should Exist
}
It "Should be able to compile a MOF from another basic configuration" -Skip:($IsMacOS -or $IsWindows) {
@ -45,10 +46,10 @@ Describe "DSC MOF Compilation" -tags "CI" {
}
}
DSCTestConfig
"@).Invoke()
DSCTestConfig -OutputPath TestDrive:\DscTestConfig2
"@) | should not throw
Remove-Item -Force -Recurse -Path DSCTestConfig
"TestDrive:\DscTestConfig2\localhost.mof" | Should Exist
}
It "Should be able to compile a MOF from a complex configuration" -Skip:($IsMacOS -or $IsWindows) {
@ -159,10 +160,59 @@ Describe "DSC MOF Compilation" -tags "CI" {
}
}
WordPressServer
"@).Invoke()
WordPressServer -OutputPath TestDrive:\DscTestConfig3
"@) | should not throw
Remove-Item -Force -Recurse -Path WordPressServer
"TestDrive:\DscTestConfig3\CentOS.mof" | Should Exist
}
It "Should be able to compile a MOF from a basic configuration on Windows" -Skip:($IsMacOS -or $IsLinux) {
[Scriptblock]::Create(@"
configuration DSCTestConfig
{
Import-DscResource -ModuleName PSDesiredStateConfiguration
Node "localhost" {
File f1
{
DestinationPath = "$env:SystemDrive\\Test.txt";
Ensure = "Present"
}
}
}
DSCTestConfig -OutputPath TestDrive:\DscTestConfig4
"@) | should not throw
"TestDrive:\DscTestConfig4\localhost.mof" | Should Exist
}
It "Should be able to compile a MOF from a configuration with multiple resources on Windows" -Skip:($IsMacOS -or $IsLinux) {
[Scriptblock]::Create(@"
configuration DSCTestConfig
{
Import-DscResource -ModuleName PSDesiredStateConfiguration
Node "localhost" {
File f1
{
DestinationPath = "$env:SystemDrive\\Test.txt";
Ensure = "Present"
}
Script s1
{
GetScript = {return @{}}
SetScript = "Write-Verbose Hello"
TestScript = {return $false}
}
Log l1
{
Message = "This is a log message"
}
}
}
DSCTestConfig -OutputPath TestDrive:\DscTestConfig5
"@) | should not throw
"TestDrive:\DscTestConfig5\localhost.mof" | Should Exist
}
}