From 69bfb99af611a634474fc07836ddf1ef62e591a8 Mon Sep 17 00:00:00 2001 From: Daniel Scott-Raynsford Date: Sat, 11 Sep 2021 19:01:00 +1200 Subject: [PATCH] Add example support for LCM Meta config #116 (#117) - Added support for examples for LCM Meta Configurations to `Test-ConfigurationName` (issue #116). --- CHANGELOG.md | 5 +++++ source/Private/Test-ConfigurationName.ps1 | 5 ++++- .../Private/Test-ConfigurationName.Tests.ps1 | 18 ++++++++++++++++++ 3 files changed, 27 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 178c6c9..b8ba2a4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +### Added + +- Added support for examples for LCM Meta Configurations to + `Test-ConfigurationName` ([issue #116](https://github.com/dsccommunity/DscResource.Test/issues/116)). + ### Changed - Refactoring all tasks to initialise variable with `Set-SamplerTaskVariable` script ([issue #110](https://github.com/dsccommunity/DscResource.Test/issues/110)). diff --git a/source/Private/Test-ConfigurationName.ps1 b/source/Private/Test-ConfigurationName.ps1 index 9a7966a..dee82d8 100644 --- a/source/Private/Test-ConfigurationName.ps1 +++ b/source/Private/Test-ConfigurationName.ps1 @@ -30,7 +30,10 @@ function Test-ConfigurationName $configurationDefinition = $definitionAst.Find($astFilter, $true) - $isOfCorrectType = $configurationDefinition.ConfigurationType -eq [System.Management.Automation.Language.ConfigurationType]::Resource + $isOfCorrectType = $configurationDefinition.ConfigurationType -in @( + [System.Management.Automation.Language.ConfigurationType]::Resource + [System.Management.Automation.Language.ConfigurationType]::Meta + ) $configurationName = $configurationDefinition.InstanceName.Value $hasEqualName = $configurationName -eq $publishFilename diff --git a/tests/Unit/Private/Test-ConfigurationName.Tests.ps1 b/tests/Unit/Private/Test-ConfigurationName.Tests.ps1 index 748f667..568bc0b 100644 --- a/tests/Unit/Private/Test-ConfigurationName.Tests.ps1 +++ b/tests/Unit/Private/Test-ConfigurationName.Tests.ps1 @@ -42,6 +42,24 @@ InModuleScope $ProjectName { } } + Context 'When a script file has the correct name but is a LCM meta configuration' { + BeforeAll { + $definition = ' + [DSCLocalConfigurationManager()] + Configuration TestConfig + { + } + ' + + $definition | Out-File -FilePath $mockScriptPath -Encoding utf8 -Force + } + + It 'Should return true' { + $result = Test-ConfigurationName -Path $mockScriptPath + $result | Should -BeTrue + } + } + Context 'When a script file has the different name than the configuration name' { BeforeAll { $definition = '