Skip to content
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

Opt-in to validate localization, and Removed 'SupportsShouldProcess' - Fixes #217 #216

Merged
merged 16 commits into from
Jul 5, 2019

Conversation

johlju
Copy link
Member

@johlju johlju commented Apr 18, 2019

Pull Request (PR) description

  • Opt-in to common test to validate localization. Fixed localization strings
    in resources - Fixes Issue #217.
  • PowerShellExecutionPolicy:
    • Removed SupportsShouldProcess as it cannot be used with DSC - Fixes
      Issue #219.
  • Combined all ComputerManagementDsc.ResourceHelper module functions into
    ComputerManagementDsc.Common module - Fixes Issue #218.
    • Minor code cleanup against style guideline.
    • Remove code from New-InvalidOperationException because it was a
      code path that could never could be used due to that the parameter
      validation prevented the helper function being called that way.
    • Updated all Get-LocalizationData to latest version from
      DSCResource.Template.
    • Fixed an issue with the helper function Test-IsNanoServer that
      prevented it to work. Though the helper function is not used, so this
      issue was not caught until now when unit tests was added.
    • Improved code coverage.

This Pull Request (PR) fixes the following issues

Task list

  • Added an entry under the Unreleased section of the change log in the CHANGELOG.md.
    Entry should say what was changed, and how that affects users (if applicable).
  • Resource documentation added/updated in README.md in the resource folder.
  • Resource parameter descriptions added/updated in schema.mof
    and comment-based help.
  • Comment-based help added/updated.
  • Localization strings added/updated in all localization files as appropriate.
  • Examples appropriately added/updated.
  • Unit tests added/updated. See DSC Resource Testing Guidelines.
  • Integration tests added/updated (where possible). See DSC Resource Testing Guidelines.
  • New/changed code adheres to DSC Resource Style Guidelines and Best Practices.

This change is Reviewable

@codecov-io
Copy link

codecov-io commented Apr 18, 2019

Codecov Report

Merging #216 into dev will increase coverage by <1%.
The diff coverage is 93%.

Impacted file tree graph

@@         Coverage Diff          @@
##            dev   #216    +/-   ##
====================================
+ Coverage    85%    86%   +<1%     
====================================
  Files        11     10     -1     
  Lines      1242   1229    -13     
====================================
- Hits       1064   1059     -5     
+ Misses      178    170     -8

@johlju
Copy link
Member Author

johlju commented Apr 30, 2019

CLosing and reopening to kick off the updated localization common test.

@johlju johlju closed this Apr 30, 2019
@johlju johlju reopened this Apr 30, 2019
@PlagueHO PlagueHO self-requested a review May 3, 2019 22:15
@PlagueHO PlagueHO added the needs review The pull request needs a code review. label May 3, 2019
@PlagueHO PlagueHO changed the title Opt-in to validate localization, and Removed 'SupportsShouldProcess' Opt-in to validate localization, and Removed 'SupportsShouldProcess' - Fixes #217 May 3, 2019
@PlagueHO
Copy link
Member

PlagueHO commented May 3, 2019

This should be able to come out of draft now that the PR to DSCResources.Test was merged.

@johlju johlju force-pushed the debubg-localization-tests branch from fa1feb3 to e7c6a36 Compare May 4, 2019 04:43
@johlju johlju marked this pull request as ready for review May 4, 2019 04:43
Copy link
Member Author

@johlju johlju left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewable status: 0 of 12 files reviewed, all discussions resolved (waiting on @PlagueHO)


Modules/ComputerManagementDsc.ResourceHelper/ComputerManagementDsc.ResourceHelper.psm1, line 51 at r1 (raw file):

Quoted 8 lines of code…
<#
    Import localization strings. This must be called after the function declaration
    of Get-LocalizedData to be able to use localized strings in the helper
    functions of this module.
#>
$script:localizedData = Get-LocalizedData `
    -ResourceName 'ComputerManagementDsc.ResourceHelper' `
    -ResourcePath $PSScriptRoot

The change to this file is not necessary. But having the en-US folder a string resource file with no keys is necessary for the new common test to pass.
If you like I can remove this change since there are no localized messages in this file.

Depending on the issue PowerShell/DscResource.Template#21 there might be another solution.

Let me know what you like me to do here. Just keep an string resource file with no keys?

@johlju
Copy link
Member Author

johlju commented May 4, 2019

@PlagueHO I'm fixing stuff for this PR to increase coverage

@johlju
Copy link
Member Author

johlju commented May 4, 2019

@PlagueHO Not sure where the last 4 misses come from.

@johlju
Copy link
Member Author

johlju commented May 4, 2019

It ready for review again! Let me knoe if I need to squash more coverage :p

@johlju johlju force-pushed the debubg-localization-tests branch from 8d81fb5 to 10ec1d6 Compare June 18, 2019 15:01
Copy link
Member

@PlagueHO PlagueHO left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry for taking so long on this @johlju - I completely missed it. I maintain an e-mail folder that contains all the GitHub e-mails from PRs I'm trying to get onto, but this wasn't in there). Sorry about that - the good thing is it was on the back log of changes I'd be intending to make as soon as I had time - and you completed it already! 😁

Reviewed 5 of 12 files at r1, 10 of 13 files at r2, 2 of 2 files at r3.
Reviewable status: all files reviewed, 6 unresolved discussions (waiting on @johlju)


CHANGELOG.md, line 32 at r3 (raw file):

  - Minor code cleanup against style guideline.
  - Remove code from `New-InvalidOperationException` because it was a
    code path that could never could be used due to that the parameter

due to that the -> due to the


CHANGELOG.md, line 33 at r3 (raw file):

  - Remove code from `New-InvalidOperationException` because it was a
    code path that could never could be used due to that the parameter
    validation prevented the helper function being called that way.

prevented -> preventing


Modules/ComputerManagementDsc.Common/ComputerManagementDsc.Common.psm1, line 4 at r3 (raw file):

    .SYNOPSIS
        Retrieves the localized string data based on the machine's culture.
        Falls back to en-US strings if the machine's culture is not supported.

Should be a blank line after each section here.


Modules/ComputerManagementDsc.Common/ComputerManagementDsc.Common.psm1, line 64 at r3 (raw file):

<#
    .SYNOPSIS
    Tests if the current machine is a Nano server.

Can you indent this line?


Modules/ComputerManagementDsc.ResourceHelper/ComputerManagementDsc.ResourceHelper.psm1, line 51 at r1 (raw file):

Previously, johlju (Johan Ljunggren) wrote…
<#
    Import localization strings. This must be called after the function declaration
    of Get-LocalizedData to be able to use localized strings in the helper
    functions of this module.
#>
$script:localizedData = Get-LocalizedData `
    -ResourceName 'ComputerManagementDsc.ResourceHelper' `
    -ResourcePath $PSScriptRoot

The change to this file is not necessary. But having the en-US folder a string resource file with no keys is necessary for the new common test to pass.
If you like I can remove this change since there are no localized messages in this file.

Depending on the issue PowerShell/DscResource.Template#21 there might be another solution.

Let me know what you like me to do here. Just keep an string resource file with no keys?

Lets keep the string resource file with no keys.


Tests/Unit/ComputerManagementDsc.Common.Tests.ps1, line 1107 at r3 (raw file):

        Describe 'DscResource.LocalizationHelper\New-InvalidOperationException' {
        Context 'When calling with Message parameter only' {

Indent seems to be wrong here.


Modules/ComputerManagementDsc.Common/en-US/ComputerManagementDsc.Common.strings.psd1, line 16 at r3 (raw file):

    TestDscParameterResultMessage      = Test-DscParameter result is '{0}'.
    CurrentTimeZoneMessage             = Current time zone is set to '{0}'
    GettingTimeZoneMessage             = Getting current time zone using {0}.

Can you put '' around {0} for consistency and readability?

@PlagueHO PlagueHO added waiting for code fix A review left open comments, and the pull request is waiting for changes to be pushed by the author. and removed needs review The pull request needs a code review. labels Jun 30, 2019
@johlju johlju force-pushed the debubg-localization-tests branch from 6b3d7db to 1c1dd4e Compare July 4, 2019 09:28
Copy link
Member Author

@johlju johlju left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ready for review again.

Reviewable status: 12 of 17 files reviewed, 6 unresolved discussions (waiting on @PlagueHO)


CHANGELOG.md, line 32 at r3 (raw file):

Previously, PlagueHO (Daniel Scott-Raynsford) wrote…

due to that the -> due to the

Done.


CHANGELOG.md, line 33 at r3 (raw file):

Previously, PlagueHO (Daniel Scott-Raynsford) wrote…

prevented -> preventing

Done.


Modules/ComputerManagementDsc.Common/ComputerManagementDsc.Common.psm1, line 4 at r3 (raw file):

Previously, PlagueHO (Daniel Scott-Raynsford) wrote…

Should be a blank line after each section here.

Done.


Modules/ComputerManagementDsc.Common/ComputerManagementDsc.Common.psm1, line 64 at r3 (raw file):

Previously, PlagueHO (Daniel Scott-Raynsford) wrote…

Can you indent this line?

Done.


Tests/Unit/ComputerManagementDsc.Common.Tests.ps1, line 1107 at r3 (raw file):

Previously, PlagueHO (Daniel Scott-Raynsford) wrote…

Indent seems to be wrong here.

Done. The entire block was duplicate to the one two blocks up.


Modules/ComputerManagementDsc.Common/en-US/ComputerManagementDsc.Common.strings.psd1, line 16 at r3 (raw file):

Previously, PlagueHO (Daniel Scott-Raynsford) wrote…

Can you put '' around {0} for consistency and readability?

Done.

Copy link
Member

@PlagueHO PlagueHO left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome job @johlju!!!!

:lgtm:

Reviewed 6 of 6 files at r4.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved

@PlagueHO PlagueHO merged commit 0b39447 into dsccommunity:dev Jul 5, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
waiting for code fix A review left open comments, and the pull request is waiting for changes to be pushed by the author.
Projects
None yet
3 participants