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

Make Invoke-Formatter test case assertion fail in case of incorrect casing #1888

Merged
merged 1 commit into from
Feb 10, 2023
Merged

Make Invoke-Formatter test case assertion fail in case of incorrect casing #1888

merged 1 commit into from
Feb 10, 2023

Conversation

alexandear
Copy link
Contributor

@alexandear alexandear commented Feb 9, 2023

PR Summary

This PR fixes the test "corrects case of of cmdlet inside interpolated string" for Invoke-Formatter. It follows #1885 which didn't fully fixed the test.

Additional Info

The idea is to use -BeExactly for case-sensitive strings comparison.
With changes in the PR the test fails when the expected string is '"$(get-childItem)"':

[-] UseCorrectCasing.corrects case of of cmdlet inside interpolated string 19ms (17ms|1ms)
 Expected strings to be the same, but they were different.
 String lengths are both 18.
 Strings differ at index 3.
 Expected: '"$(get-childItem)"'
 But was:  '"$(Get-ChildItem)"'
            ---^
 at Invoke-Formatter '"$(get-childitem)"' | Should -BeExactly '"$(get-childItem)"', /Users/redko.o/src/github.com/PowerShell/PSScriptAnalyzer/Tests/Rules/UseCorrectCasing.tests.ps1:14
 at <ScriptBlock>, /Users/redko.o/src/github.com/PowerShell/PSScriptAnalyzer/Tests/Rules/UseCorrectCasing.tests.ps1:14

PR Checklist

Copy link
Collaborator

@bergmeister bergmeister left a comment

Choose a reason for hiding this comment

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

thanks for helping us catch this as well. You are totally right.
cc @kilasuit

@bergmeister bergmeister changed the title Fix Invoke-Formatter correct case test Make Invoke-Formatter test case assertion fail in case of incorrect casing Feb 10, 2023
@bergmeister bergmeister merged commit 8826d1c into PowerShell:master Feb 10, 2023
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