Version 1.0.0 Release #1
2
.gitignore
vendored
2
.gitignore
vendored
@@ -1,3 +1,3 @@
|
||||
.git
|
||||
.sample
|
||||
.output
|
||||
.tests
|
||||
@@ -1,132 +0,0 @@
|
||||
$script:ModuleRoot = Split-Path -Parent $PSScriptRoot
|
||||
$script:SampleRoot = Join-Path -Path $script:ModuleRoot -ChildPath ".sample"
|
||||
|
||||
Import-Module (Join-Path -Path $script:ModuleRoot -ChildPath "Merge-DSCConfigurationData.psd1") -Force
|
||||
|
||||
Describe "Merge-ConfigurationData" {
|
||||
It "merges wildcard instance templates into all deployment instances" {
|
||||
$Template = Import-PowerShellDataFile (Join-Path -Path $script:SampleRoot -ChildPath "Template.psd1")
|
||||
$Deployment = Import-PowerShellDataFile (Join-Path -Path $script:SampleRoot -ChildPath "Deployment.psd1")
|
||||
|
||||
$Result = Merge-ConfigurationData -Template $Template -Deployment $Deployment
|
||||
$Instances = @($Result.NonNodeData.Services.SQLServer.Instances)
|
||||
|
||||
$Instances.Count | Should Be 2
|
||||
($Instances.Name -contains "*") | Should Be $false
|
||||
|
||||
foreach($Name in @("MSSQLSERVER", "MSSQLSERVERTEST")){
|
||||
$Instance = $Instances | Where-Object { $_.Name -eq $Name }
|
||||
|
||||
$Instance | Should Not BeNullOrEmpty
|
||||
$Instance.Features | Should Be "SQLENGINE,FULLTEXT"
|
||||
$Instance.ConfigurationOptions.Count | Should Be 4
|
||||
$Instance.AdditionalScripts.Count | Should Be 6
|
||||
$Instance.Memory | Should Not BeNullOrEmpty
|
||||
$Instance.Directories | Should Not BeNullOrEmpty
|
||||
}
|
||||
}
|
||||
|
||||
It "does not merge an exact instance template into another instance name" {
|
||||
$Template = @{
|
||||
NonNodeData = @{
|
||||
Services = @{
|
||||
SQLServer = @{
|
||||
Instances = @(
|
||||
@{
|
||||
Name = "MSSQLSERVER"
|
||||
Marker = "exact-only"
|
||||
}
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$Deployment = @{
|
||||
NonNodeData = @{
|
||||
Services = @{
|
||||
SQLServer = @{
|
||||
Instances = @(
|
||||
@{ Name = "MSSQLSERVER" },
|
||||
@{ Name = "MSSQLSERVERTEST" }
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$Result = Merge-ConfigurationData -Template $Template -Deployment $Deployment
|
||||
$Instances = @($Result.NonNodeData.Services.SQLServer.Instances)
|
||||
|
||||
($Instances | Where-Object { $_.Name -eq "MSSQLSERVER" }).Marker | Should Be "exact-only"
|
||||
($Instances | Where-Object { $_.Name -eq "MSSQLSERVERTEST" }).Marker | Should BeNullOrEmpty
|
||||
}
|
||||
|
||||
It "uses the name-key fallback for unknown arrays" {
|
||||
$Template = @{
|
||||
Databases = @(
|
||||
@{
|
||||
DatabaseName = "AppDb"
|
||||
RecoveryModel = "Full"
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
$Deployment = @{
|
||||
Databases = @(
|
||||
@{
|
||||
DatabaseName = "AppDb"
|
||||
Owner = "dbo"
|
||||
},
|
||||
@{
|
||||
DatabaseName = "LogDb"
|
||||
Owner = "dbo"
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
$Result = Merge-ConfigurationData -Template $Template -Deployment $Deployment
|
||||
$Databases = @($Result.Databases)
|
||||
|
||||
($Databases | Where-Object { $_.DatabaseName -eq "AppDb" }).RecoveryModel | Should Be "Full"
|
||||
($Databases | Where-Object { $_.DatabaseName -eq "LogDb" }).RecoveryModel | Should BeNullOrEmpty
|
||||
}
|
||||
|
||||
It "uses Key and ValueName together for registry array merges" {
|
||||
$Template = @{
|
||||
Basic = @{
|
||||
Registry = @(
|
||||
@{
|
||||
Key = "K1"
|
||||
ValueName = "Enabled"
|
||||
Default = "Template-K1"
|
||||
},
|
||||
@{
|
||||
Key = "K2"
|
||||
ValueName = "Enabled"
|
||||
Default = "Template-K2"
|
||||
}
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
$Deployment = @{
|
||||
Basic = @{
|
||||
Registry = @(
|
||||
@{
|
||||
Key = "K1"
|
||||
ValueName = "Enabled"
|
||||
ValueData = "Deployment-K1"
|
||||
}
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
$Result = Merge-ConfigurationData -Template $Template -Deployment $Deployment
|
||||
$Registry = @($Result.Basic.Registry)
|
||||
|
||||
($Registry | Where-Object { $_.Key -eq "K1" }).Default | Should Be "Template-K1"
|
||||
($Registry | Where-Object { $_.Key -eq "K1" }).ValueData | Should Be "Deployment-K1"
|
||||
($Registry | Where-Object { $_.Key -eq "K2" }).Default | Should Be "Template-K2"
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user