-
Notifications
You must be signed in to change notification settings - Fork 9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Adding latest version of 'Test-DscParameterState' from JeaDsc #46
Conversation
…rties' and added 'ExcludeProperties'
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@raandree Awesome work! A few comments.
Reviewed 6 of 6 files at r1.
Reviewable status: all files reviewed, 10 unresolved discussions (waiting on @raandree)
README.md, line 551 at r1 (raw file):
[[-ExcludeProperties] <string[]>] [-TurnOffTypeChecking] [-ReverseCheck]
I'm missing the renamed parameterProperties
here?
README.md, line 588 at r1 (raw file):
-ExcludeProperties
Should this be Properties
and that we should have a new example that shows how to use ExcludeProperties
?
source/en-US/DscResource.Common.strings.psd1, line 12 at r1 (raw file):
InvalidExcludePropertiesError = If 'DesiredValues' is a CimInstance then property 'ExcludeProperties' must contain a value. (DRC0016)
Is this text correct? The localization key string is used when evaluating the parameter Properties
. 🤔
source/Public/Test-DscParameterState.ps1, line 55 at r1 (raw file):
-ExcludeProperties @(
Should this be Properties
and we should have another example for ExcludeProperties
?
source/Public/Test-DscParameterState.ps1, line 87 at r1 (raw file):
[switch]
Please change to [System.Management.Automation.SwitchParameter]
source/Public/Test-DscParameterState.ps1, line 91 at r1 (raw file):
[switch]
Please change to [System.Management.Automation.SwitchParameter]
source/Public/Test-DscParameterState.ps1, line 95 at r1 (raw file):
[switch]
Please change to [System.Management.Automation.SwitchParameter]
source/Public/Test-DscParameterState.ps1, line 132 at r1 (raw file):
Quoted 6 lines of code…
if ($DesiredValues -is [Microsoft.Management.Infrastructure.CimInstance] -and -not $Properties) { New-InvalidArgumentException ` -Message $script:localizedData.InvalidExcludePropertiesError ` -ArgumentName 'ExcludeProperties' }
Is this text correct? We evaluate the parameter Properties
, but throws an exception for ExcludeProperties
. 🤔
Was it meant to have another evaluation for the property ExcludeProperties
?
See comment in the localization strings as well.
source/Public/Test-DscParameterState.ps1, line 148 at r1 (raw file):
Where-Object { $_ -notin $ExcludeProperties }
Use named parameters Where-Object -FilterScript { $_ -notin $ExcludeProperties }
tests/Unit/Public/Test-DscParameterState.Tests.ps1, line 741 at r1 (raw file):
} }
Remove extra blank line
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewable status: all files reviewed, 11 unresolved discussions (waiting on @raandree)
tests/Unit/Public/Test-DscParameterState.Tests.ps1, line 227 at r1 (raw file):
Context 'When a value is mismatched but ExcludeProperties is used to exclude then' {
This test test ValuesToCheck
before, that was renamed to Properties
. So should this test the parameter Properties
and there should be another test (this test) to test the parameter ExcludeProperties
?
Also, we should add a test the calls using the alias ValuesToCheck
as well so that works as expected.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewable status: 1 of 6 files reviewed, 12 unresolved discussions (waiting on @johlju)
README.md, line 551 at r1 (raw file):
ExcludeProperties
Sorry, I was thinking that the readme.ms is auto-generated using the help. I have updated the section.
README.md, line 588 at r1 (raw file):
Previously, johlju (Johan Ljunggren) wrote…
-ExcludeProperties
Should this be
Properties
and that we should have a new example that shows how to useExcludeProperties
?
Done.
source/en-US/DscResource.Common.strings.psd1, line 12 at r1 (raw file):
InvalidExcludePropertiesError
source/en-US/DscResource.Common.strings.psd1, line 12 at r1 (raw file):
InvalidExcludePropertiesError Right, thanks for the correction!
source/Public/Test-DscParameterState.ps1, line 55 at r1 (raw file):
Previously, johlju (Johan Ljunggren) wrote…
-ExcludeProperties @(
Should this be
Properties
and we should have another example forExcludeProperties
?
We have not one sample for the parameter 'Properties' and one for 'ExcludeProperties'. If the examples should be more detailed, please let me know.
source/Public/Test-DscParameterState.ps1, line 87 at r1 (raw file):
Previously, johlju (Johan Ljunggren) wrote…
[switch]
Please change to
[System.Management.Automation.SwitchParameter]
Done.
source/Public/Test-DscParameterState.ps1, line 91 at r1 (raw file):
Previously, johlju (Johan Ljunggren) wrote…
[switch]
Please change to
[System.Management.Automation.SwitchParameter]
Done.
source/Public/Test-DscParameterState.ps1, line 95 at r1 (raw file):
Previously, johlju (Johan Ljunggren) wrote…
[switch]
Please change to
[System.Management.Automation.SwitchParameter]
Done.
source/Public/Test-DscParameterState.ps1, line 132 at r1 (raw file):
Previously, johlju (Johan Ljunggren) wrote…
if ($DesiredValues -is [Microsoft.Management.Infrastructure.CimInstance] -and -not $Properties) { New-InvalidArgumentException ` -Message $script:localizedData.InvalidExcludePropertiesError ` -ArgumentName 'ExcludeProperties' }
Is this text correct? We evaluate the parameter
Properties
, but throws an exception forExcludeProperties
. 🤔
Was it meant to have another evaluation for the propertyExcludeProperties
?See comment in the localization strings as well.
Done.
source/Public/Test-DscParameterState.ps1, line 148 at r1 (raw file):
Previously, johlju (Johan Ljunggren) wrote…
Where-Object { $_ -notin $ExcludeProperties }
Use named parameters
Where-Object -FilterScript { $_ -notin $ExcludeProperties }
Done.
tests/Unit/Public/Test-DscParameterState.Tests.ps1, line 227 at r1 (raw file):
When a value is mismatched but
This test makes more sense as only one property of the desired values is different from the current values. I have added another test for 'Properties'
tests/Unit/Public/Test-DscParameterState.Tests.ps1, line 741 at r1 (raw file):
Previously, johlju (Johan Ljunggren) wrote…
Remove extra blank line
Done.
What is the difference between 'Compare-ResourcePropertyState' in #48 and 'Test-DscParameterState'? Do we have two functions now doing the same thing? |
First I'm very happy we get this PR that updates The difference is that they are two different design patterns. While There are many modules that are using Btw. I tried to reuse |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a few more tiny changes. Then it will be ready to merge I think.
Reviewed 5 of 5 files at r2.
Reviewable status: all files reviewed, 4 unresolved discussions (waiting on @raandree)
README.md, line 551 at r1 (raw file):
Previously, raandree (Raimund Andrée [MSFT]) wrote…
ExcludeProperties
Sorry, I was thinking that the readme.ms is auto-generated using the help. I have updated the section.
Unfortunately no , I want that in the future. I'm thinking of adding auto-documentation for this in the future (maybe part of the module DscResource.DocGenerator). But so many things that would be fun to do, but so little time. 😄
Looks good to me now.
source/Public/Test-DscParameterState.ps1, line 55 at r1 (raw file):
Previously, raandree (Raimund Andrée [MSFT]) wrote…
We have not one sample for the parameter 'Properties' and one for 'ExcludeProperties'. If the examples should be more detailed, please let me know.
Could we add the example you added in the README.md to here too? Then we have the correct examples if we do auto-doc in the future.
source/Public/Test-DscParameterState.ps1, line 133 at r2 (raw file):
-ArgumentName 'ExcludeProperties'
This should be 'Properties'
now?
tests/Unit/Public/Test-DscParameterState.Tests.ps1, line 310 at r2 (raw file):
It 'Should return $false' { $script:result | Should -BeFalse }
Could we add a nested context-block after the It-block that regression tests the ValuesToCheck
alias?
Example:
Context 'When using the alias ValuesToCheck' {
It 'Should not throw exception' {
{ $script:result = Test-DscParameterState `
-CurrentValues $currentValues `
-DesiredValues $desiredValues `
-Properties $properties `
-Verbose:$verbose } | Should -Not -Throw
}
It 'Should return $false' {
$script:result | Should -BeFalse
}
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the explanation. IMHO we should merge both patterns to remove redundancy. Another task on the list...
Reviewable status: all files reviewed, 4 unresolved discussions (waiting on @johlju)
source/en-US/DscResource.Common.strings.psd1, line 12 at r1 (raw file):
InvalidExcludePropertiesError
I am not sure what this particular section was about. I have renamed the message 'InvalidExcludePropertiesError' to 'InvalidPropertiesError'.
source/Public/Test-DscParameterState.ps1, line 55 at r1 (raw file):
Previously, johlju (Johan Ljunggren) wrote…
Could we add the example you added in the README.md to here too? Then we have the correct examples if we do auto-doc in the future.
Done.
source/Public/Test-DscParameterState.ps1, line 133 at r2 (raw file):
Previously, johlju (Johan Ljunggren) wrote…
-ArgumentName 'ExcludeProperties'
This should be
'Properties'
now?
Done.
tests/Unit/Public/Test-DscParameterState.Tests.ps1, line 310 at r2 (raw file):
Previously, johlju (Johan Ljunggren) wrote…
Could we add a nested context-block after the It-block that regression tests the
ValuesToCheck
alias?Example:
Context 'When using the alias ValuesToCheck' { It 'Should not throw exception' { { $script:result = Test-DscParameterState ` -CurrentValues $currentValues ` -DesiredValues $desiredValues ` -Properties $properties ` -Verbose:$verbose } | Should -Not -Throw } It 'Should return $false' { $script:result | Should -BeFalse } }
Done.
Really looking forward to this (& compare-), I think it will really help improve the DSC Resources quality & reduce effort in the longer run. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed 2 of 3 files at r3, 3 of 3 files at r4.
Reviewable status: all files reviewed, 1 unresolved discussion
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewable status: all files reviewed, 2 unresolved discussions (waiting on @raandree)
tests/Unit/Public/Test-DscParameterState.Tests.ps1, line 289 at r4 (raw file):
It 'Should return $false' { $script:result | Should -BeFalse
I think this should be $true instead, similar to the test that follows this.
@raandree the last test is failing the tests, see review comment. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed 1 of 1 files at r5.
Reviewable status: all files reviewed, 1 unresolved discussion
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed 1 of 1 files at r6.
Reviewable status: all files reviewed, 1 unresolved discussion
Pull Request (PR) description
Adding latest version of 'Test-DscParameterState' from JeaDsc.
Test-DscParameterState
can now handle scriptblocks.This Pull Request (PR) fixes the following issues
NA
Task list
file CHANGELOG.md. Entry should say what was changed and how that
affects users (if applicable), and reference the issue being resolved
(if applicable).
DSC Community Testing Guidelines.
This change is