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

SharePoint PowerShell unit test are not disconnecting #1591

Open
james-garriss opened this issue Feb 21, 2025 · 2 comments
Open

SharePoint PowerShell unit test are not disconnecting #1591

james-garriss opened this issue Feb 21, 2025 · 2 comments
Labels
Testing This issue or task involves testing the automation tool function
Milestone

Comments

@james-garriss
Copy link
Collaborator

🐛 Summary

Found this error in the CI Pipeline, in the PowerShell unit tests:

WARNING: Could not disconnect from sharepoint
: The term 'Disconnect-PnPOnline' is not recognized as the name of a cmdlet, function, script file, or operable 
program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.

This looks like an oversight in mocking the Disconnect modules. The cmdlet isn't mocked like all the other disconnect cmdlets in this test are. Since the assumption is they are mocked, the proper import is not used. But this test doesn't require actually running Disconnect-PnPOnline. I believe it just needs to be mocked.

To reproduce

Look here:

https://github.com/cisagov/ScubaGear/actions/runs/13456805458/job/37602667447

Expected behavior

If test is failing, it should fail the unit test rather than failing silently. If it's not really a failure, then it should be mocked properly.

@james-garriss
Copy link
Collaborator Author

David Bui identified that the issue is occurring here:

https://github.com/cisagov/ScubaGear/blob/main/PowerShell/ScubaGear/Testing/Unit/PowerShell/Connection/Disconnect-SCuBATenant.Tests.ps1

He believes it is a tiny fix.

@buidav
Copy link
Collaborator

buidav commented Feb 21, 2025

David Bui identified that the issue is occurring here:

https://github.com/cisagov/ScubaGear/blob/main/PowerShell/ScubaGear/Testing/Unit/PowerShell/Connection/Disconnect-SCuBATenant.Tests.ps1

He believes it is a tiny fix.

Just add this to the line up of mocks.

function Disconnect-PnPOnline {throw 'this will be mocked'}
Mock  -ModuleName Connection Disconnect-PnPOnline {}

@schrolla schrolla added the Testing This issue or task involves testing the automation tool function label Feb 24, 2025
@schrolla schrolla added this to the Backlog milestone Feb 24, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Testing This issue or task involves testing the automation tool function
Projects
None yet
Development

No branches or pull requests

3 participants