Skip to content

Commit

Permalink
Add example support for LCM Meta config #116 (#117)
Browse files Browse the repository at this point in the history
- Added support for examples for LCM Meta Configurations to
  `Test-ConfigurationName` (issue #116).
  • Loading branch information
PlagueHO authored Sep 11, 2021
1 parent 9c24b35 commit 69bfb99
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 1 deletion.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)).
Expand Down
5 changes: 4 additions & 1 deletion source/Private/Test-ConfigurationName.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
18 changes: 18 additions & 0 deletions tests/Unit/Private/Test-ConfigurationName.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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 = '
Expand Down

0 comments on commit 69bfb99

Please sign in to comment.