-
Notifications
You must be signed in to change notification settings - Fork 139
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
Adds xADComputer Resource #96
Conversation
…into dev Conflicts: README.md
…into dev # Conflicts: # README.md
…into Issue69 # Conflicts: # DSCResources/MSFT_xADUser/MSFT_xADUser.psm1 # README.md
One for you @PlagueHO! |
@iainbrighton - You're a legend! I'll review tonight (unless someone else gets there first)! 👍 |
Reviewed 1 of 2 files at r1, 11 of 11 files at r2. README.md, line 233 [r2] (raw file):
You should add a mention of fixing the verbose log messages and the changes (minor) to xADGroup and xADUser. DSCResources/MSFT_xADCommon/MSFT_xADCommon.ps1, line 303 [r2] (raw file):
Nitpick: Even though you didn't add it, can we remove the 2nd semicolon at the end of the line? Tests/Unit/MSFT_xADComputer.Tests.ps1, line 4 [r2] (raw file):
Can you convert the template into the new version (v1.1.0) Unit Test Template? Tests/Unit/MSFT_xADComputer.Tests.ps1, line 28 [r2] (raw file):
You should probably get rid of the InModuleScope block as it isn't required. The templates got changed a few weeks ago to remove this so that it was only included when private functions needed to be tested. Tests/Unit/MSFT_xADComputer.Tests.ps1, line 56 [r2] (raw file):
PSSA is probably going to throw a hissy fit about this line so we'd need to add a [Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSAvoidUsingConvertToSecureStringWithPlainText", "")] Comments from Reviewable |
Review status: all files reviewed at latest revision, 5 unresolved discussions. README.md, line 233 [r2] (raw file):
|
Removes extraneous semicolon
Review status: 10 of 12 files reviewed at latest revision, 5 unresolved discussions. Tests/Unit/MSFT_xADComputer.Tests.ps1, line 4 [r2] (raw file):
|
Superb work on this BTW! 👍
|
Thinking about this (on the train), isn't the module imported inside the TestHelper scope? This is a different scope to where the Pester tests are executed and might be why they can't be found..?
|
@iainbrighton - oh my - you could very well be correct. That would make a lot of sense. I say we use InModuleScope until we figure out a solution. If there is no solution then we need to revert the Test.Templates and the TestGuidelines. @KarolKaczmarek, @narrieta - can you think of a way around this problem: If the DSC Resource being tested is being imported by the Test.Helper.psm1 module, not by the actual unit test script, then it is not in the scope of the unit test script - so the tests needs to be in an InModuleScope block. |
@PlagueHO - in my opinion the module to test should be imported within the scope of the test script, rather than in the scope of Test.Helper.psm1. Importing at the global scope (Import-Module -Global) may also work, though I think the first option would be preferable. One question regarding the import: Initialize-TestEnvironment explicitly removes the module before importing it. Is Import-Module -Force not enough? One observation about Initialize-TestEnvironment: when I tried to execute the unit tests for ADComputer my PowerShell session seemed to hang so I had to kill the process. From then on, all the new PowerShell instances I started were extremely slow. The issue turned out to be duplicated entries in PSModulePath. Initialize-TestEnvironment changes the module path at the machine level; consider changing it at the process level and checking for duplicates. The execution policy should probably also be changed at the process level. |
@narrieta - thank you for looking at this and the info. Regarding the Import-Module -Force - I think you're right, using the -Force parameter should be enough. As for the Initialize-TestEnvironment problems, there is actually an issue in place that relates to this. I'm looking at doing some work on this but was just waiting to get a bit more feed back before proceeding. But it looks like the issues are really mounting up with this stuff so I might just go ahead and PR a solution and let people comment on that. I do agree though, the PSModulePath should only be changed at the process level - but only for the unit tests. For the integration tests to work this still requires the machine level changes because the LCM runs under a different process. Thanks again for commenting on this - sorry @iainbrighton for hijacking this PR. |
@PlagueHO @narrieta No problem! If the import in the TestHelper.psm1 is changed to However, I can't seem to then mock the internal calls to Get-TargetResource from the Test- and Set-TargetResource functions without the InModuleScope [sigh]. |
@iainbrighton @PlagueHO OK, too bad -Global doesn't work. I would recommend then importing the module to test from the test script instead of from TestHelper.psm1. It may be a small inconvenience but then only the code that actually needs access to the privates of the module needs to use InModuleScope (instead of the entire code of the test). Especially if we are doing this in the template that new test should follow. |
@narrieta, @iainbrighton - I've moved this issue out into a new issue in DSCResource.tests. Thanks heaps for looking into all of this. |
Reviewed 1 of 2 files at r1, 7 of 11 files at r2, 3 of 4 files at r3. Tests/Unit/MSFT_xADComputer.Tests.ps1, line 4 [r2] (raw file):
|
Review status: all files reviewed at latest revision, 2 unresolved discussions. Tests/Unit/MSFT_xADComputer.Tests.ps1, line 4 [r2] (raw file):
|
Review status: all files reviewed at latest revision, 2 unresolved discussions. Tests/Unit/MSFT_xADComputer.Tests.ps1, line 4 [r2] (raw file):
|
I reviewed, two discussions waiting on @iainbrighton and @PlagueHO to say they are satisfied with the resolution.
|
Review status: all files reviewed at latest revision, 2 unresolved discussions. Tests/Unit/MSFT_xADComputer.Tests.ps1, line 56 [r2] (raw file):
|
Review status: all files reviewed at latest revision, 2 unresolved discussions. Tests/Unit/MSFT_xADComputer.Tests.ps1, line 56 [r2] (raw file):
|
This change is![Reviewable](https://camo.githubusercontent.com/23b05f5fb48215c989e92cc44cf6512512d083132bd3daf689867c8d9d386888/68747470733a2f2f72657669657761626c652e696f2f7265766965775f627574746f6e2e737667)