Skip to content
This repository has been archived by the owner on Jun 13, 2024. It is now read-only.

Add ability to override Pester script parameters and specify version of module to execute #12

Merged
merged 20 commits into from
Apr 27, 2017

Conversation

devblackops
Copy link
Contributor

@devblackops devblackops commented Oct 6, 2016

This PR adds the ability to pass script parameters to Pester tests referenced in issue #6 as well as the ability to specify the version of the module to execute in the event that there are multiple versions of the OVF module in $PSModulePath.

If a Pester script inside an OVF module had a parameter block like so:

param(
    [int]$SomeValue = 100
    [bool]$ExtraChecks = $false
)

Describe 'foo' {
    Context 'bar' {
        ...
    }
}

then those parameters can be overridden by injecting new values in the form of a [hashtable] when calling Invoke-OperationValidation

Example

Invoke-OperationValidation -ModuleName MyModule -Overrides @{ SomeValue = 50; ExtraChecks = $true }

This change is Reviewable

@msftclas
Copy link

msftclas commented Oct 6, 2016

Hi @devblackops, I'm your friendly neighborhood Microsoft Pull Request Bot (You can call me MSBOT). Thanks for your contribution!

In order for us to evaluate and accept your PR, we ask that you sign a contribution license agreement. It's all electronic and will take just minutes. I promise there's no faxing. https://cla.microsoft.com.

TTYL, MSBOT;

@msftclas
Copy link

msftclas commented Oct 6, 2016

@devblackops, Thanks for signing the contribution license agreement so quickly! Actual humans will now validate the agreement and then evaluate the PR.

Thanks, MSBOT;

@devblackops
Copy link
Contributor Author

@JamesWTruher Any comment on this PR?

@devblackops
Copy link
Contributor Author

@JamesWTruher Who at Microsoft is responsible for maintaining this module? Is it just you or are there others that can take a look at this? I'd like to see some traction or PR review. This is a super useful module but if it takes ages to get a PR through or even to get a discussion going, I don't see it going anywhere.

@ngetchell
Copy link

Some feedback on this PR would be nice. This is something I'd use heavily if implemented.

As I invest more time into OVF I'd like to know there is active development behind it.

@ngetchell
Copy link

After speaking with @devblackops he mentioned that this PR adds tag support. I haven't tried his implementation out yet but I'm excited. The Simple/Comprehensive designation seemed arbitrary. Being able to use my own tags from Pester to better categorize my OVF tests would be great.

@devblackops
Copy link
Contributor Author

Small clarification. This PR does NOT add tag support. Just support for providing parameters to Pester scripts and OVF module versions. Tag support is in this branch in my fork. That branch includes the changes in this PR as well. Once I do a little more testing, I'll submit a PR to add tag support. That is, if anyone at Microsoft will review and comment 😏

@JamesWTruher
Copy link
Contributor

sorry about the delay, I'm not getting notifications for some reason. I like this PR, but could we add some tests to validate the new functionality?

# Did we specify a specific version to find?
if ($PSBoundParameters.ContainsKey('Version'))
{
$manifestFile = Get-ChildItem -Path $modDir.FullName -Filter "$modDir.psd1" | Select-Object -First 1
Copy link
Contributor

Choose a reason for hiding this comment

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

$modDir [](start = 102, length = 7)

when I see write things like this, i usually like to use "${modDir}.psd1" just to avoid confusion

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Indeed. I've changed it to "$($obj.prop)" syntax

@devblackops
Copy link
Contributor Author

Thanks for responding @JamesWTruher. I'll make the required changes to tests and let you know when this can be reviewed again.

Expect a similar PR to come in that adds tag support referenced in #10

@devblackops
Copy link
Contributor Author

Hi @JamesWTruher
I tweeked some minor things and added a few tests to validate script parameters can be overridden. This also handles a change in Pester 4.0 behavior as the -Quiet parameter is deprecated now.

I believe this is ready to merge.

Cheers.

@JamesWTruher JamesWTruher merged commit 14a5939 into PowerShell:master Apr 27, 2017
@JamesWTruher
Copy link
Contributor

thanks!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants