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

Help Wanted: Convert tests to Pester 5 #1654

Closed
59 of 62 tasks
johlju opened this issue Dec 22, 2020 · 4 comments · Fixed by #1550
Closed
59 of 62 tasks

Help Wanted: Convert tests to Pester 5 #1654

johlju opened this issue Dec 22, 2020 · 4 comments · Fixed by #1550
Labels
tests The issue or pull request is about tests only.

Comments

@johlju
Copy link
Member

johlju commented Dec 22, 2020

I appreciate if you are willing to help converting tests.

There is a PR #1550 currently in draft where community can add converted test that locally passes in Pester 5. Due to that Pester 5 is not really backward compatible ALL test must be converted and merged in one go. Pester 5 is a big improvement how to write and adds stability to run tests. Can we get the tests converted we can use future features that will be added to Pester.

How to help

  1. Clone the working branch in @johlju's fork to the current folder.
git clone -b f/support-pester-5 https://github.com/johlju/SqlServerDsc
cd SqlServerDsc
  1. Create your own working-branch
git checkout -b f/my-working-branch
  1. Run the following to prepare the environment.
# Downloads prerequisites into the './output' folder 
.\build.ps1 -ResolveDependency -Tasks noop
# Builds the module and prepares to run/debug tests (builds the module to './output'.
.\build.ps1 -Tasks build
  1. Convert a test below that haven't yet been converted.
  2. You can run tests by using Invoke-Pester from console like below, or run/debug the from within Visual Studio code (see note above).
# run entire file
Invoke-Pester .\tests\Unit\DSC_SqlProtocol.Tests.ps1 -Output Detailed
# or run just the describe block with tag 'Get'
Invoke-Pester .\tests\Unit\DSC_SqlProtocol.Tests.ps1 -Output Detailed -Tag Get 
  1. Create a remote to your own fork (assumes you have forked it in GitHub already).
    Replace the URL with your username, e.g. https://github.com/johlju/SqlServerDsc
git remote add my https://github.com/<MyGitHubUserName>/SqlServerDsc
  1. Push the changes to your fork.
git push my
  1. Send a pull request (PR) to @johlju's fork https://github.com/johlju/SqlServerDsc and target the working branch f/support-pester-5.
  2. Mention @johlju in the PR to merge it. On merge it will automatically update PR BREAKING CHANGE: SqlServerDsc: Support Pester 5 #1550.
  3. @johlju will update this issue to check off any finished tests.

NOTE: If you use Visual Studio Code to write and debug test make sure to run .\build.ps -task build in the
PowerShell Integrated Console inside Visual Studio Code . This makes sure the environment is ready to
debug tests. If the module have already been built then fastest is to run .\build.ps -task noop.

What needs to be done

These tests need to be converted. See an existing converted unit test to see the pattern needed.

Read the blog post to know how Pester 5 tests should look like: https://dsccommunity.org/blog/convert-tests-to-pester5-for-dsc-community-repository/

Unit tests

These unit tests need to be converted.

  • DSC_SqlAG.Tests.ps1
  • DSC_SqlAGDatabase.Tests.ps1
  • DSC_SqlAGListener.Tests.ps1
  • DSC_SqlAGReplica.Tests.ps1
  • DSC_SqlAgentAlert.Tests.ps1
  • DSC_SqlAgentFailsafe.Tests.ps1
  • DSC_SqlAgentOperator.Tests.ps1
  • DSC_SqlAlias.Tests.ps1
  • DSC_SqlAlwaysOnService.Tests.ps1
  • DSC_SqlConfiguration.Tests.ps1
  • DSC_SqlDatabase.Tests.ps1
  • DSC_SqlDatabaseDefaultLocation.Tests.ps1
  • DSC_SqlDatabaseMail.Tests.ps1
  • DSC_SqlDatabaseObjectPermission.Tests.ps1
  • DSC_SqlDatabasePermission.Tests.ps1
  • DSC_SqlDatabaseRole.Tests.ps1
  • DSC_SqlDatabaseUser.Tests.ps1
  • DSC_SqlEndpoint.Tests.ps1
  • DSC_SqlEndpointPermission.Tests.ps1
  • DSC_SqlLogin.Tests.ps1
  • DSC_SqlMaxDop.Tests.ps1
  • DSC_SqlMemory.Tests.ps1
  • DSC_SqlPermission.Tests.ps1
  • DSC_SqlProtocol.Tests.ps1
  • DSC_SqlProtocolTcpIp.Tests.ps1
  • DSC_SqlRS.Tests.ps1
  • DSC_SqlRSSetup.Tests.ps1
  • DSC_SqlReplication.Tests.ps1
  • DSC_SqlRole.Tests.ps1
  • DSC_SqlScript.Tests.ps1
  • DSC_SqlScriptQuery.Tests.ps1
  • DSC_SqlSecureConnection.Tests.ps1
  • DSC_SqlServiceAccount.Tests.ps1
  • DSC_SqlSetup.Tests.ps1
  • DSC_SqlTraceFlag.Tests.ps1
  • DSC_SqlWaitForAG.Tests.ps1
  • DSC_SqlWindowsFirewall.Tests.ps1
  • SqlServerDSC.Common.Tests.ps1
  • SqlServerDsc.AnalyzerRules.Tests.ps1

Integration tests

These integration tests need to be converted.

  • DSC_SqlAgentAlert.Integration.Tests.ps1
  • DSC_SqlAgentFailsafe.Integration.Tests.ps1
  • DSC_SqlAgentOperator.Integration.Tests.ps1
  • DSC_SqlAlwaysOnService.Integration.Tests.ps1
  • DSC_SqlDatabase.Integration.Tests.ps1
  • DSC_SqlDatabaseDefaultLocation.Integration.Tests.ps1
  • DSC_SqlDatabaseMail.Integration.Tests.ps1
  • DSC_SqlDatabaseObjectPermission.Integration.Tests.ps1
  • DSC_SqlDatabasePermission.Integration.Tests.ps1
  • DSC_SqlDatabaseUser.Integration.Tests.ps1
  • DSC_SqlEndpoint.Integration.Tests.ps1
  • DSC_SqlLogin.Integration.Tests.ps1
  • DSC_SqlProtocol.Integration.Tests.ps1
  • DSC_SqlProtocolTcpIp.Integration.Tests.ps1
  • DSC_SqlRS.Integration.Tests.ps1
  • DSC_SqlRSSetup.Integration.Tests.ps1
  • DSC_SqlReplication.Integration.Tests.ps1
  • DSC_SqlRole.Integration.Tests.ps1
  • DSC_SqlScript.Integration.Tests.ps1
  • DSC_SqlScriptQuery.Integration.Tests.ps1
  • DSC_SqlSecureConnection.Integration.Tests.ps1
  • DSC_SqlServiceAccount.Integration.Tests.ps1
  • DSC_SqlSetup.Integration.Tests.ps1
@johlju johlju pinned this issue Dec 22, 2020
@johlju johlju added help wanted The issue is up for grabs for anyone in the community. tests The issue or pull request is about tests only. labels Dec 22, 2020
@Fiander
Copy link
Contributor

Fiander commented Dec 27, 2020

@johlju
Hi,
hope you had a fine christmas :-)

i just finished SqlRole and SqlTraceFlag, but i am kinda stuck at step 5 in the above example.

thanks to step 1 i only have a local branch, and have no clue how to create a pull request for that (local) branch.
did i mis something? am i stupid, or should i fork it first next time before entering step 1 ( or do all of the three options validate to $true?)

@johlju
Copy link
Member Author

johlju commented Dec 27, 2020

Ah, good point, I missed that step. 😊 You have to add a remote to your own fork. Do this before step 5. 😊

git remote add my https://github.com/<githubusername>/SqlServerDsc

I think you can also branch out by running (I’m not sure it possible to rename on push):

git push my new-working-branch

Or just do this which will push current branch to your fork.

git push my

Then send in that working branch as a PR to my fork.

Christmas was great! Hope you had a great Christmas too! 😊

@johlju
Copy link
Member Author

johlju commented Dec 31, 2020

Updated the issue description with the above.

@johlju johlju added the in progress The issue is being actively worked on by someone. label Feb 26, 2022
@johlju johlju removed the in progress The issue is being actively worked on by someone. label Jun 6, 2022
@johlju johlju unpinned this issue Jun 7, 2022
@johlju johlju removed the help wanted The issue is up for grabs for anyone in the community. label Jun 7, 2022
@johlju
Copy link
Member Author

johlju commented Jun 7, 2022

The remaining tests to refactor are being tracked in issues #1752, #1753, #1754.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
tests The issue or pull request is about tests only.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants