Skip to content
This repository has been archived by the owner on Sep 4, 2020. It is now read-only.

New Function: Get-VesterTest #157

Closed
brianbunke opened this issue Jun 16, 2017 · 2 comments
Closed

New Function: Get-VesterTest #157

brianbunke opened this issue Jun 16, 2017 · 2 comments
Assignees

Comments

@brianbunke
Copy link
Contributor

This "current" vs. "expected" info is valid as of release 1.1.0.

Current Behavior

Want to run just VM tests, instead of all included tests?
Want to run all DNS tests included with the module?

Get-ChildItem "$((Get-Module Vester).ModuleBase)\Tests\VM\" | Invoke-Vester
Get-ChildItem "$((Get-Module Vester).ModuleBase)\Tests\" -Filter *dns* -File -Recurse | Invoke-Vester

Want to know what a test file does in plain English? Open the test file in an editor to view the $Description.

Expected Behavior

# Run all VM tests included with the module
Get-VesterTest -Scope VM | Invoke-Vester

# Run all tests matching *dns*.Vester.ps1 included with the module
Get-VesterTest -Name dns | Invoke-Vester

Get-VesterTest should return info about a file's contents, so that you could do something like this to figure out what a test does:

Get-VesterTest -Name NTP-Service-Policy
# Would return: FullName (Path) and all variable definitions within (like $Description)
# Probably subject to a format xml to modify default displayed returns

Possible Solution

New public function Get-VesterTest

  • Wraps Get-ChildItem and always includes:
    • -File
    • -Recurse
    • -Filter '*.vester.ps1'
  • Defaults to -Path "$((Get-Module Vester).ModuleBase)\Tests\"

Parameters:

  • -Name: Wildcard searches the Vester test filenames
    • Would modify -Filter '*.vester.ps1' --> -Filter "*$Name*.vester.ps1"
  • -Scope: A [ValidateSet()] param for all scopes Vester ships

Context

Piping Get-VesterTest with basic info is a lot easier than expecting every single user to know how to perform the Get-ChildItem examples shown above.

Users should not have to dig into .ps1 files to view basic info (like $Description) about an included Vester test file.

@brianbunke
Copy link
Contributor Author

brianbunke commented Jul 12, 2017

Tackling this in branch 157test of my fork.

WahlNetwork:dd2f179...brianbunke:26c6244

PR requirements:

  • Get-VesterTest works as described above, standalone
  • Write cmdlet-based help
  • Update Invoke-Vester flow to accommodate the Get-VesterTest changes
  • Update Invoke-Vester examples

To avoid future tech debt, the would-be-nice list:

  • Add unit tests for Get-VesterTest
  • Add unit tests for new private functions

@brianbunke
Copy link
Contributor Author

brianbunke commented Jul 26, 2017

WahlNetwork:dd2f179...brianbunke:8e0d949

I implemented Get-VesterTest -Simple, which returns just the full file path. Vester currently expects to just pass a path string down to the private template, and the test extraction happens within the private template. This feels re-writable now, but not as part of this issue/PR.

I also can't pipe them in right now (Get-VesterTest | Invoke-Vester) because config files take precedence. Bleh.

Submitting the PR now.

chriswahl added a commit that referenced this issue Jul 26, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

1 participant