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

Add hook package for pester test validation #8

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

steviecoaster
Copy link

This PR adds a hook package to this repository which allows for the execution of pester tests from within a tests folder included in a Chocolatey package.

This commit adds a hook package to this repository which executes any
pester tests that have been included in a tests folder inside the package.

Package parameters are provided to allow skipping of execution of the pester
tests to allow for other hooks that may be required to run as opposed to using
the global --skip-hooks parameter.
Copy link
Member

@TheCakeIsNaOH TheCakeIsNaOH left a comment

Choose a reason for hiding this comment

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

I'm not super familiar with Pester, but the actual running of the tests looks ok, but there are some comments on the use of package parameters.

<description>This hook package adds scripts that execute Pester tests for a package after the execution of `chocolateyInstall.ps1`.
To run validation include pester tests inside a `tests` folder inside the package.

## Package Parameters:
Copy link
Member

Choose a reason for hiding this comment

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

This could be read as package parameters available while installing pester-validation.hook, not package parameters available when the hook is already installed.

}

if ($testDir) {
if (-not $pp['SkipPackageValidation']) {
Copy link
Member

Choose a reason for hiding this comment

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

When writing the hooks, I had not really considered usage of package parameters. This was due to concerns of conflicts between parameters for packages, and parameters for hooks. There are some packages on CCR where the parsing of parameters is not ideal, and they could potentially have issues with unexpected parameters, who knows how many internal packages could have issues. Also, if a package parameter has an arbitrary name, it could set something in both a hook and the package, where only one was intended.

Currently, there is the --skip-hooks, which I had though should take care of disabling hooks when needed. Then for configuration, after discussion with @gep13, using the Chocolatey configuration file to store configuration values was the best option for configuring hooks. Use the choco config command to set, and use a helper to read the values (PR here chocolatey/choco#2952).

I had thought that most hooks would be "install and forget", or "configure once and forget", but it looks like that might not be the case. Maybe we need to add a switch to Chocolatey to skip individual hooks, or this hook could be switched to use a configuration value? I'd welcome other thoughts on this.

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.

2 participants