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

Ensure we're testing module functions and logic #66

Open
vexx32 opened this issue Aug 31, 2022 · 0 comments · May be fixed by #79
Open

Ensure we're testing module functions and logic #66

vexx32 opened this issue Aug 31, 2022 · 0 comments · May be fixed by #79
Labels
0 - Backlog Bug Something isn't working
Milestone

Comments

@vexx32
Copy link
Member

vexx32 commented Aug 31, 2022

What You Are Seeing?

Many tests shadow the actual module function with an ad-hoc function that does nothing and only the tests use. As a result, there aren't really any tests for the module logic itself.

What is Expected?

Tests should be verifying the module behaves as intended given various inputs and outputs of mocked functions.

How Did You Get This To Happen? (Steps to Reproduce)

See for example:

$module = (Get-ChildItem "$($env:BuildRepositoryLocalPath)" -Recurse -Filter *.psd1).FullName[1]
Import-Module $module -Force
Function Get-CCMComputer {
param($Computer)
Invoke-RestMethod -Uri 'https://google.com'
}

System Details

N/A

Output Log

N/A

@vexx32 vexx32 added Bug Something isn't working 0 - Backlog labels Aug 31, 2022
@vexx32 vexx32 added this to the 0.10.0 milestone Aug 31, 2022
@vexx32 vexx32 changed the title Test module functions Ensure we're testing module functions and logic Aug 31, 2022
JPRuskin added a commit to JPRuskin/ChocoCCM that referenced this issue May 6, 2023
Adds test covering public functions within ChocoCCM.

Admittedly, currently only ~66% code coverage.

This does, however, hit pretty much every _working_ command - most of the missing percentage are argument completers (which I am to improve), `if not session throw` blocks (which I aim to remove), and those commands that aren't working. Exceptions to be improved include:
- Set-CCMDeploymentStep, which isn't implemented fully and should probably just be removed for now.
- Remove-CCMStaleDeployment, which is currently broken
- Import-PDQDeployPackage, because I couldn't find an example of an importable file.
JPRuskin added a commit to JPRuskin/ChocoCCM that referenced this issue May 6, 2023
These were not terribly useful now we had the new tests in place.

Also removes the non-existent function `Get-CCMDeploymentStepResult` from the PSD1, after improving the "has all the functions available" test (which showed this disparity).
JPRuskin added a commit to JPRuskin/ChocoCCM that referenced this issue May 6, 2023
Removes the -All parameter from Get-CCMDeployment, which means this might work.

Adjusts the test to be a little better.
JPRuskin added a commit to JPRuskin/ChocoCCM that referenced this issue May 6, 2023
Unless we intended to provide regex-matching functionality here (which isn't obvious from the help), this fixes the ability to return multiple computers with a single name (or even random regex query).
@JPRuskin JPRuskin linked a pull request May 6, 2023 that will close this issue
6 tasks
JPRuskin added a commit to JPRuskin/ChocoCCM that referenced this issue May 6, 2023
Adds test covering public functions within ChocoCCM.

Admittedly, currently only ~66% code coverage.

This does, however, hit pretty much every _working_ command - most of the missing percentage are argument completers (which I am to improve), `if not session throw` blocks (which I aim to remove), and those commands that aren't working. Exceptions to be improved include:
- Set-CCMDeploymentStep, which isn't implemented fully and should probably just be removed for now.
- Remove-CCMStaleDeployment, which is currently broken
- Import-PDQDeployPackage, because I couldn't find an example of an importable file.
JPRuskin added a commit to JPRuskin/ChocoCCM that referenced this issue May 6, 2023
These were not terribly useful now we had the new tests in place.

Also removes the non-existent function `Get-CCMDeploymentStepResult` from the PSD1, after improving the "has all the functions available" test (which showed this disparity).
JPRuskin added a commit to JPRuskin/ChocoCCM that referenced this issue May 6, 2023
Removes the -All parameter from Get-CCMDeployment, which means this might work.

Adjusts the test to be a little better.
JPRuskin added a commit to JPRuskin/ChocoCCM that referenced this issue May 6, 2023
Unless we intended to provide regex-matching functionality here (which isn't obvious from the help), this fixes the ability to return multiple computers with a single name (or even random regex query).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
0 - Backlog Bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant