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

xVirtualMemory: Refactor and improve unit test coverage and HQRM - Fixes #95 #96

Merged
merged 4 commits into from
Aug 25, 2017

Conversation

PlagueHO
Copy link
Member

@PlagueHO PlagueHO commented Aug 17, 2017

Pull Request (PR) description
This PR refactors xVirtualMemory to:

  • reduce code duplication
  • improve testability (it was very difficult to unit test)
  • meet HQRM standards
  • increase unit test coverage to 95%
  • convert exception calling to use CommonResourceHelper.psm1
  • moved strings into localization file

This Pull Request (PR) fixes the following issues:
Fixes #95
Fixes #81

Task list:

  • Change details added to Unreleased section of CHANGELOG.md?
  • Added/updated documentation, comment-based help and descriptions in .schema.mof files where appropriate?
  • Examples appropriately updated?
  • New/changed code adheres to Style Guidelines?
  • Unit and (optional) Integration tests created/updated where possible?

@johlju - sorry about the size of this PR, but once I took a look at the existing code and unit tests, I found it wasn't going to be easy to get decent coverage without refactoring. The same with HQRM - the resource needed a lot of work to get it into decent shape.


This change is Reviewable

@PlagueHO PlagueHO added the needs review The pull request needs a code review. label Aug 17, 2017
@PlagueHO PlagueHO added this to the HQRM milestone Aug 17, 2017
@PlagueHO PlagueHO self-assigned this Aug 17, 2017
@codecov-io
Copy link

codecov-io commented Aug 17, 2017

Codecov Report

Merging #96 into dev will increase coverage by 9%.
The diff coverage is 94%.

Impacted file tree graph

@@        Coverage Diff        @@
##           dev   #96   +/-   ##
=================================
+ Coverage   68%   78%   +9%     
=================================
  Files        6     6           
  Lines      725   706   -19     
=================================
+ Hits       499   552   +53     
+ Misses     226   154   -72

@johlju
Copy link
Member

johlju commented Aug 17, 2017

I have some problems over at xSQLServer that I need to focus on. But will get to this as soon as those bugs are squashed.

@PlagueHO
Copy link
Member Author

Absolutely no problem or rush @johlju - just whenever! I'm planning another PR against this repo to fix #85 so that one would take precedence in getting reviewed over this one.

@johlju
Copy link
Member

johlju commented Aug 23, 2017

Awesome work as usual. Just minor things.


Reviewed 4 of 4 files at r1.
Review status: all files reviewed at latest revision, 17 unresolved discussions.


DSCResources/MSFT_xVirtualMemory/MSFT_xVirtualMemory.psm1, line 45 at r1 (raw file):

[bool]

Change to [System.Boolean]?


DSCResources/MSFT_xVirtualMemory/MSFT_xVirtualMemory.psm1, line 50 at r1 (raw file):

    {
        $returnValue.Type = 'AutoManagePagingFile'
        return $returnValue

Maybe use else instead of returning here, and in another location, and only return at the end? But good as is too. Non-blocking.


DSCResources/MSFT_xVirtualMemory/MSFT_xVirtualMemory.psm1, line 385 at r1 (raw file):

}

function Set-PageFileSetting

Missed comment-based help here.


DSCResources/MSFT_xVirtualMemory/en-US/MSFT_xVirtualMemory.strings.psd1, line 7 at r1 (raw file):

Specifting

This was a new word for me ;)


Tests/Unit/MSFT_xVirtualMemory.Tests.ps1, line 197 at r1 (raw file):

                    -Verifiable

                It 'Should not return a valid type and drive letter' {

"Should not..." seems wrong here, it does return something.


Tests/Unit/MSFT_xVirtualMemory.Tests.ps1, line 237 at r1 (raw file):

                    -Verifiable

                It 'Should not return a valid type and drive letter' {

Same here


Tests/Unit/MSFT_xVirtualMemory.Tests.ps1, line 351 at r1 (raw file):

                        -Verifiable

                    It 'Should return false' {

Wrong text here.


Tests/Unit/MSFT_xVirtualMemory.Tests.ps1, line 428 at r1 (raw file):

                        -Verifiable

                    It 'Should return false' {

Same here


Tests/Unit/MSFT_xVirtualMemory.Tests.ps1, line 504 at r1 (raw file):

                            -Verifiable

                        It 'Should return false' {

Same here


Tests/Unit/MSFT_xVirtualMemory.Tests.ps1, line 576 at r1 (raw file):

                        -Verifiable

                    It 'Should return false' {

Same here


Tests/Unit/MSFT_xVirtualMemory.Tests.ps1, line 639 at r1 (raw file):

                            -CommandName Remove-CimInstance

                        It 'Should return false' {

Same here


Tests/Unit/MSFT_xVirtualMemory.Tests.ps1, line 696 at r1 (raw file):

                        -Verifiable

                    It 'Should return false' {

Same here


Tests/Unit/MSFT_xVirtualMemory.Tests.ps1, line 734 at r1 (raw file):

With

When?


Tests/Unit/MSFT_xVirtualMemory.Tests.ps1, line 764 at r1 (raw file):

With

When?


Tests/Unit/MSFT_xVirtualMemory.Tests.ps1, line 1133 at r1 (raw file):

                        -Verifiable

                    It 'Should not return the expected object' {

Add a test when it do return the correct object?


Tests/Unit/MSFT_xVirtualMemory.Tests.ps1, line 1141 at r1 (raw file):

                    It 'Should call the correct mocks' {
                        Assert-VerifiableMocks

Do you need this? Throughout


Tests/Unit/MSFT_xVirtualMemory.Tests.ps1, line 1206 at r1 (raw file):

throw exception

unsure, but maybe "throw an exception"? Throughout


Comments from Reviewable

@PlagueHO
Copy link
Member Author

All fixed I think! Great review, thanks @johlju


Review status: 1 of 4 files reviewed at latest revision, 17 unresolved discussions.


DSCResources/MSFT_xVirtualMemory/MSFT_xVirtualMemory.psm1, line 45 at r1 (raw file):

Previously, johlju (Johan Ljunggren) wrote…

[bool]

Change to [System.Boolean]?

Done.


DSCResources/MSFT_xVirtualMemory/MSFT_xVirtualMemory.psm1, line 50 at r1 (raw file):

Previously, johlju (Johan Ljunggren) wrote…

Maybe use else instead of returning here, and in another location, and only return at the end? But good as is too. Non-blocking.

Done.


DSCResources/MSFT_xVirtualMemory/MSFT_xVirtualMemory.psm1, line 385 at r1 (raw file):

Previously, johlju (Johan Ljunggren) wrote…

Missed comment-based help here.

Done.


DSCResources/MSFT_xVirtualMemory/en-US/MSFT_xVirtualMemory.strings.psd1, line 7 at r1 (raw file):

Previously, johlju (Johan Ljunggren) wrote…

Specifting

This was a new word for me ;)

Oops - good catch - not really sure how I ended up with that!


Tests/Unit/MSFT_xVirtualMemory.Tests.ps1, line 197 at r1 (raw file):

Previously, johlju (Johan Ljunggren) wrote…

"Should not..." seems wrong here, it does return something.

Done.


Tests/Unit/MSFT_xVirtualMemory.Tests.ps1, line 237 at r1 (raw file):

Previously, johlju (Johan Ljunggren) wrote…

Same here

Done.


Tests/Unit/MSFT_xVirtualMemory.Tests.ps1, line 351 at r1 (raw file):

Previously, johlju (Johan Ljunggren) wrote…

Wrong text here.

Done.


Tests/Unit/MSFT_xVirtualMemory.Tests.ps1, line 428 at r1 (raw file):

Previously, johlju (Johan Ljunggren) wrote…

Same here

Done.


Tests/Unit/MSFT_xVirtualMemory.Tests.ps1, line 504 at r1 (raw file):

Previously, johlju (Johan Ljunggren) wrote…

Same here

Done.


Tests/Unit/MSFT_xVirtualMemory.Tests.ps1, line 576 at r1 (raw file):

Previously, johlju (Johan Ljunggren) wrote…

Same here

Done.


Tests/Unit/MSFT_xVirtualMemory.Tests.ps1, line 639 at r1 (raw file):

Previously, johlju (Johan Ljunggren) wrote…

Same here

Done.


Tests/Unit/MSFT_xVirtualMemory.Tests.ps1, line 696 at r1 (raw file):

Previously, johlju (Johan Ljunggren) wrote…

Same here

Done.


Tests/Unit/MSFT_xVirtualMemory.Tests.ps1, line 734 at r1 (raw file):

Previously, johlju (Johan Ljunggren) wrote…

With

When?

Done.


Tests/Unit/MSFT_xVirtualMemory.Tests.ps1, line 764 at r1 (raw file):

Previously, johlju (Johan Ljunggren) wrote…

With

When?

Done.


Tests/Unit/MSFT_xVirtualMemory.Tests.ps1, line 1133 at r1 (raw file):

Previously, johlju (Johan Ljunggren) wrote…

Add a test when it do return the correct object?

Oops. Is actually testing for the correct object.


Tests/Unit/MSFT_xVirtualMemory.Tests.ps1, line 1141 at r1 (raw file):

Previously, johlju (Johan Ljunggren) wrote…

Do you need this? Throughout

No not needed - removed throughout.


Tests/Unit/MSFT_xVirtualMemory.Tests.ps1, line 1206 at r1 (raw file):

Previously, johlju (Johan Ljunggren) wrote…

throw exception

unsure, but maybe "throw an exception"? Throughout

Done.


Comments from Reviewable

@johlju
Copy link
Member

johlju commented Aug 25, 2017

:lgtm:


Reviewed 3 of 3 files at r2.
Review status: all files reviewed at latest revision, all discussions resolved.


Comments from Reviewable

@PlagueHO PlagueHO merged commit e98a911 into dsccommunity:dev Aug 25, 2017
@joeyaiello joeyaiello removed the needs review The pull request needs a code review. label Aug 25, 2017
@PlagueHO PlagueHO deleted the Issue-95 branch August 25, 2017 21:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

xVirtualMemory: Improve Unit Test Coverage Reach at least 70% Unit Test Code Coverage
5 participants