-
Notifications
You must be signed in to change notification settings - Fork 8.1k
Refactor Installer and Host Tests to Pester 4 Syntax #6283
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
Changes from all commits
41ef1e4
6137170
7e7774a
a8350c0
c28cb31
1b6ab18
63a2220
486a62c
0d1e792
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,6 @@ | ||
| # Copyright (c) Microsoft Corporation. All rights reserved. | ||
| # Licensed under the MIT License. | ||
|
|
||
| Describe "InvokeOnRunspace method argument error handling" -tags "Feature" { | ||
|
|
||
| BeforeAll { | ||
|
|
@@ -16,7 +17,7 @@ Describe "InvokeOnRunspace method argument error handling" -tags "Feature" { | |
| } | ||
| catch | ||
| { | ||
| $_.FullyQualifiedErrorId | Should Be "PSArgumentNullException" | ||
| $_.FullyQualifiedErrorId | Should -Be "PSArgumentNullException" | ||
| } | ||
| } | ||
|
|
||
|
|
@@ -29,7 +30,7 @@ Describe "InvokeOnRunspace method argument error handling" -tags "Feature" { | |
| } | ||
| catch | ||
| { | ||
| $_.FullyQualifiedErrorId | Should Be "PSArgumentNullException" | ||
| $_.FullyQualifiedErrorId | Should -Be "PSArgumentNullException" | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should be |
||
| } | ||
| } | ||
| } | ||
|
|
@@ -44,7 +45,7 @@ Describe "InvokeOnRunspace method as nested command" -tags "Feature" { | |
|
|
||
| $results = [System.Management.Automation.HostUtilities]::InvokeOnRunspace($command, $currentRunspace) | ||
|
|
||
| $results[0] | Should Be "Hello!" | ||
| $results[0] | Should -Be "Hello!" | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should be |
||
| } | ||
| } | ||
|
|
||
|
|
@@ -71,6 +72,6 @@ Describe "InvokeOnRunspace method on remote runspace" -tags "Feature" { | |
|
|
||
| $results = [System.Management.Automation.HostUtilities]::InvokeOnRunspace($command, $script:remoteRunspace) | ||
|
|
||
| $results[0] | Should Be "Hello!" | ||
| $results[0] | Should -Be "Hello!" | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should be |
||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,6 @@ | ||
| # Copyright (c) Microsoft Corporation. All rights reserved. | ||
| # Licensed under the MIT License. | ||
|
|
||
| Describe "PSVersionTable" -Tags "CI" { | ||
|
|
||
| BeforeAll { | ||
|
|
@@ -25,51 +26,51 @@ Describe "PSVersionTable" -Tags "CI" { | |
| } | ||
|
|
||
| It "Should have version table entries" { | ||
| $PSVersionTable.Count | Should Be 9 | ||
| $PSVersionTable.Count | Should -Be 9 | ||
| } | ||
|
|
||
| It "Should have the right version table entries" { | ||
| $PSVersionTable.ContainsKey("PSVersion") | Should Be True | ||
| $PSVersionTable.ContainsKey("PSEdition") | Should Be True | ||
| $PSVersionTable.ContainsKey("WSManStackVersion") | Should Be True | ||
| $PSVersionTable.ContainsKey("SerializationVersion") | Should Be True | ||
| $PSVersionTable.ContainsKey("PSCompatibleVersions") | Should Be True | ||
| $PSVersionTable.ContainsKey("PSRemotingProtocolVersion") | Should Be True | ||
| $PSVersionTable.ContainsKey("GitCommitId") | Should Be True | ||
| $PSVersionTable.ContainsKey("Platform") | Should Be True | ||
| $PSVersionTable.ContainsKey("OS") | Should Be True | ||
| $PSVersionTable.ContainsKey("PSVersion") | Should -BeTrue | ||
| $PSVersionTable.ContainsKey("PSEdition") | Should -BeTrue | ||
| $PSVersionTable.ContainsKey("WSManStackVersion") | Should -BeTrue | ||
| $PSVersionTable.ContainsKey("SerializationVersion") | Should -BeTrue | ||
| $PSVersionTable.ContainsKey("PSCompatibleVersions") | Should -BeTrue | ||
| $PSVersionTable.ContainsKey("PSRemotingProtocolVersion") | Should -BeTrue | ||
| $PSVersionTable.ContainsKey("GitCommitId") | Should -BeTrue | ||
| $PSVersionTable.ContainsKey("Platform") | Should -BeTrue | ||
| $PSVersionTable.ContainsKey("OS") | Should -BeTrue | ||
|
|
||
| } | ||
|
|
||
| It "PSVersion property" { | ||
| $PSVersionTable.PSVersion | Should BeOfType "System.Management.Automation.SemanticVersion" | ||
| $PSVersionTable.PSVersion | Should BeExactly $expectedPSVersion | ||
| $PSVersionTable.PSVersion | Should Match $expectedVersionPattern | ||
| $PSVersionTable.PSVersion.Major | Should Be 6 | ||
| $PSVersionTable.PSVersion | Should -BeOfType "System.Management.Automation.SemanticVersion" | ||
| $PSVersionTable.PSVersion | Should -BeExactly $expectedPSVersion | ||
| $PSVersionTable.PSVersion | Should -Match $expectedVersionPattern | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| $PSVersionTable.PSVersion.Major | Should -Be 6 | ||
| } | ||
|
|
||
| It "GitCommitId property" { | ||
| $PSVersionTable.GitCommitId | Should BeOfType "System.String" | ||
| $PSVersionTable.GitCommitId | Should Match $expectedGitCommitIdPattern | ||
| $PSVersionTable.GitCommitId | Should Not Match $unexpectectGitCommitIdPattern | ||
| $PSVersionTable.GitCommitId | Should BeExactly $rawGitCommitId | ||
| $PSVersionTable.GitCommitId | Should -BeOfType "System.String" | ||
| $PSVersionTable.GitCommitId | Should -Match $expectedGitCommitIdPattern | ||
| $PSVersionTable.GitCommitId | Should -Not -Match $unexpectectGitCommitIdPattern | ||
| $PSVersionTable.GitCommitId | Should -BeExactly $rawGitCommitId | ||
| } | ||
|
|
||
| It "Should have the correct platform info" { | ||
| $platform = [String][System.Environment]::OSVersion.Platform | ||
| [String]$PSVersionTable["Platform"] | Should Be $platform | ||
| [String]$PSVersionTable["Platform"] | Should -Be $platform | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should be |
||
| } | ||
|
|
||
| It "Should have the correct OS info" { | ||
| if ($IsCoreCLR) | ||
| { | ||
| $OSDescription = [String][System.Runtime.InteropServices.RuntimeInformation]::OSDescription | ||
| [String]$PSVersionTable["OS"] | Should Be $OSDescription | ||
| [String]$PSVersionTable["OS"] | Should -Be $OSDescription | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should be |
||
| } | ||
| else | ||
| { | ||
| $OSDescription = [String][System.Environment]::OSVersion | ||
| [String]$PSVersionTable["OS"] | Should Be $OSDescription | ||
| [String]$PSVersionTable["OS"] | Should -Be $OSDescription | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should be |
||
| } | ||
| } | ||
|
|
||
|
|
@@ -81,27 +82,27 @@ Describe "PSVersionTable" -Tags "CI" { | |
| { | ||
| $edition = "Desktop" | ||
| } | ||
| $PSVersionTable["PSEdition"] | Should Be $edition | ||
| $PSVersionTable["PSEdition"] | Should -Be $edition | ||
| } | ||
|
|
||
| It "Verify `$PSVersionTable is ordered and 'PSVersion' is on first place" { | ||
| $PSVersionName = "PSVersion" | ||
| $keys1 = ($PSVersionTable | Format-Table -HideTableHeaders -Property Name | Out-String) -split [System.Environment]::NewLine | Where-Object {$_} | ForEach-Object {$_.Trim()} | ||
|
|
||
| $keys1[0] | Should Be "PSVersion" | ||
| $keys1[1] | Should Be "PSEdition" | ||
| $keys1[0] | Should -Be "PSVersion" | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should be |
||
| $keys1[1] | Should -Be "PSEdition" | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should be |
||
|
|
||
| $keys1last = $keys1[2..($keys1.length-1)] | ||
| $keys1sortedlast = $keys1last | Sort-Object | ||
|
|
||
| Compare-Object -ReferenceObject $keys1last -DifferenceObject $keys1sortedlast -SyncWindow 0 | Should Be $null | ||
| Compare-Object -ReferenceObject $keys1last -DifferenceObject $keys1sortedlast -SyncWindow 0 | Should -Be $null | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should be |
||
| } | ||
|
|
||
| It "Verify `$PSVersionTable can be formatted correctly when it has non-string key" { | ||
| try { | ||
| $key = Get-Item $PSScriptRoot | ||
| $PSVersionTable.Add($key, "TEST") | ||
| { $PSVersionTable | Format-Table } | Should Not Throw | ||
| { $PSVersionTable | Format-Table } | Should -Not -Throw | ||
| } finally { | ||
| $PSVersionTable.Remove($key) | ||
| } | ||
|
|
@@ -113,12 +114,12 @@ Describe "PSVersionTable" -Tags "CI" { | |
| $PSVersionTable.Remove("PSVersion") | ||
|
|
||
| $keys1 = ($PSVersionTable | Format-Table -HideTableHeaders -Property Name | Out-String) -split [System.Environment]::NewLine | Where-Object {$_} | ForEach-Object {$_.Trim()} | ||
| $keys1[0] | Should Be "PSEdition" | ||
| $keys1.Length | Should Be $PSVersionTable.Count | ||
| $keys1[0] | Should -Be "PSEdition" | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should be |
||
| $keys1.Length | Should -Be $PSVersionTable.Count | ||
|
|
||
| $keys1last = $keys1[1..($keys1.length-1)] | ||
| $keys1sortedlast = $keys1last | Sort-Object | ||
| Compare-Object -ReferenceObject $keys1last -DifferenceObject $keys1sortedlast -SyncWindow 0 | Should Be $null | ||
| Compare-Object -ReferenceObject $keys1last -DifferenceObject $keys1sortedlast -SyncWindow 0 | Should -Be $null | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should be |
||
| } finally { | ||
| $PSVersionTable.Add("PSVersion", $VersionValue) | ||
| } | ||
|
|
@@ -130,12 +131,12 @@ Describe "PSVersionTable" -Tags "CI" { | |
| $PSVersionTable.Remove("PSEdition") | ||
|
|
||
| $keys1 = ($PSVersionTable | Format-Table -HideTableHeaders -Property Name | Out-String) -split [System.Environment]::NewLine | Where-Object {$_} | ForEach-Object {$_.Trim()} | ||
| $keys1[0] | Should Be "PSVersion" | ||
| $keys1.Length | Should Be $PSVersionTable.Count | ||
| $keys1[0] | Should -Be "PSVersion" | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should be |
||
| $keys1.Length | Should -Be $PSVersionTable.Count | ||
|
|
||
| $keys1last = $keys1[1..($keys1.length-1)] | ||
| $keys1sortedlast = $keys1last | Sort-Object | ||
| Compare-Object -ReferenceObject $keys1last -DifferenceObject $keys1sortedlast -SyncWindow 0 | Should Be $null | ||
| Compare-Object -ReferenceObject $keys1last -DifferenceObject $keys1sortedlast -SyncWindow 0 | Should -Be $null | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should be |
||
| } finally { | ||
| $PSVersionTable.Add("PSEdition", $EditionValue) | ||
| } | ||
|
|
@@ -149,10 +150,10 @@ Describe "PSVersionTable" -Tags "CI" { | |
| $PSVersionTable.Remove("PSEdition") | ||
|
|
||
| $keys1 = ($PSVersionTable | Format-Table -HideTableHeaders -Property Name | Out-String) -split [System.Environment]::NewLine | Where-Object {$_} | ForEach-Object {$_.Trim()} | ||
| $keys1.Length | Should Be $PSVersionTable.Count | ||
| $keys1.Length | Should -Be $PSVersionTable.Count | ||
|
|
||
| $keys1sortedlast = $keys1 | Sort-Object | ||
| Compare-Object -ReferenceObject $keys1 -DifferenceObject $keys1sortedlast -SyncWindow 0 | Should Be $null | ||
| Compare-Object -ReferenceObject $keys1 -DifferenceObject $keys1sortedlast -SyncWindow 0 | Should -Be $null | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should be |
||
| } finally { | ||
| $PSVersionTable.Add("PSVersion", $VersionValue) | ||
| $PSVersionTable.Add("PSEdition", $EditionValue) | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,41 +1,42 @@ | ||
| # Copyright (c) Microsoft Corporation. All rights reserved. | ||
| # Licensed under the MIT License. | ||
|
|
||
| Describe "Tab completion bug fix" -Tags "CI" { | ||
|
|
||
| It "Issue#682 - '[system.manage<tab>' should work" { | ||
| $result = TabExpansion2 -inputScript "[system.manage" -cursorColumn "[system.manage".Length | ||
| $result | Should Not BeNullOrEmpty | ||
| $result.CompletionMatches.Count | Should Be 1 | ||
| $result.CompletionMatches[0].CompletionText | Should Be "System.Management" | ||
| $result | Should -Not -BeNullOrEmpty | ||
| $result.CompletionMatches.Count | Should -Be 1 | ||
| $result.CompletionMatches[0].CompletionText | Should -Be "System.Management" | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should be |
||
| } | ||
|
|
||
| It "Issue#1350 - '1 -sp<tab>' should work" { | ||
| $result = TabExpansion2 -inputScript "1 -sp" -cursorColumn "1 -sp".Length | ||
| $result | Should Not BeNullOrEmpty | ||
| $result.CompletionMatches.Count | Should Be 1 | ||
| $result.CompletionMatches[0].CompletionText | Should Be "-split" | ||
| $result | Should -Not -BeNullOrEmpty | ||
| $result.CompletionMatches.Count | Should -Be 1 | ||
| $result.CompletionMatches[0].CompletionText | Should -Be "-split" | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should be |
||
| } | ||
|
|
||
| It "Issue#1350 - '1 -a<tab>' should work" { | ||
| $result = TabExpansion2 -inputScript "1 -a" -cursorColumn "1 -a".Length | ||
| $result | Should Not BeNullOrEmpty | ||
| $result.CompletionMatches.Count | Should Be 2 | ||
| $result.CompletionMatches[0].CompletionText | Should Be "-and" | ||
| $result.CompletionMatches[1].CompletionText | Should Be "-as" | ||
| $result | Should -Not -BeNullOrEmpty | ||
| $result.CompletionMatches.Count | Should -Be 2 | ||
| $result.CompletionMatches[0].CompletionText | Should -Be "-and" | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should be |
||
| $result.CompletionMatches[1].CompletionText | Should -Be "-as" | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should be |
||
| } | ||
| It "Issue#2295 - '[pscu<tab>' should expand to [pscustomobject]" { | ||
| $result = TabExpansion2 -inputScript "[pscu" -cursorColumn "[pscu".Length | ||
| $result | Should Not BeNullOrEmpty | ||
| $result.CompletionMatches.Count | Should Be 1 | ||
| $result.CompletionMatches[0].CompletionText | Should Be "pscustomobject" | ||
| $result | Should -Not -BeNullOrEmpty | ||
| $result.CompletionMatches.Count | Should -Be 1 | ||
| $result.CompletionMatches[0].CompletionText | Should -Be "pscustomobject" | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should be |
||
| } | ||
| It "Issue#1345 - 'Import-Module -n<tab>' should work" { | ||
| $cmd = "Import-Module -n" | ||
| $result = TabExpansion2 -inputScript $cmd -cursorColumn $cmd.Length | ||
| $result.CompletionMatches.Count | Should Be 3 | ||
| $result.CompletionMatches[0].CompletionText | Should Be "-Name" | ||
| $result.CompletionMatches[1].CompletionText | Should Be "-NoClobber" | ||
| $result.CompletionMatches[2].CompletionText | Should Be "-NoOverwrite" | ||
| $result.CompletionMatches.Count | Should -Be 3 | ||
| $result.CompletionMatches[0].CompletionText | Should -Be "-Name" | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should be |
||
| $result.CompletionMatches[1].CompletionText | Should -Be "-NoClobber" | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should be |
||
| $result.CompletionMatches[2].CompletionText | Should -Be "-NoOverwrite" | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should be |
||
| } | ||
| Context "Issue#3416 - 'Select-Object'" { | ||
| BeforeAll { | ||
|
|
@@ -44,25 +45,25 @@ Describe "Tab completion bug fix" -Tags "CI" { | |
| It "Issue#3416 - 'Select-Object -ExcludeProperty <tab>' should work" { | ||
| $cmd = "Get-Date | Select-Object -ExcludeProperty " | ||
| $result = TabExpansion2 -inputScript $cmd -cursorColumn $cmd.Length | ||
| $result.CompletionMatches.Count | Should Be $DatetimeProperties.Count | ||
| $result.CompletionMatches[0].CompletionText | Should Be $DatetimeProperties[0].Name # Date | ||
| $result.CompletionMatches[1].CompletionText | Should Be $DatetimeProperties[1].Name # DateTime | ||
| $result.CompletionMatches.Count | Should -Be $DatetimeProperties.Count | ||
| $result.CompletionMatches[0].CompletionText | Should -Be $DatetimeProperties[0].Name # Date | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should be |
||
| $result.CompletionMatches[1].CompletionText | Should -Be $DatetimeProperties[1].Name # DateTime | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should be |
||
| } | ||
| It "Issue#3416 - 'Select-Object -ExpandProperty <tab>' should work" { | ||
| $cmd = "Get-Date | Select-Object -ExpandProperty " | ||
| $result = TabExpansion2 -inputScript $cmd -cursorColumn $cmd.Length | ||
| $result.CompletionMatches.Count | Should Be $DatetimeProperties.Count | ||
| $result.CompletionMatches[0].CompletionText | Should Be $DatetimeProperties[0].Name # Date | ||
| $result.CompletionMatches[1].CompletionText | Should Be $DatetimeProperties[1].Name # DateTime | ||
| $result.CompletionMatches.Count | Should -Be $DatetimeProperties.Count | ||
| $result.CompletionMatches[0].CompletionText | Should -Be $DatetimeProperties[0].Name # Date | ||
| $result.CompletionMatches[1].CompletionText | Should -Be $DatetimeProperties[1].Name # DateTime | ||
| } | ||
| } | ||
|
|
||
| It "Issue#3628 - 'Sort-Object @{<tab>' should work" { | ||
| $cmd = "Get-Date | Sort-Object @{" | ||
| $result = TabExpansion2 -inputScript $cmd -cursorColumn $cmd.Length | ||
| $result.CompletionMatches.Count | Should Be 3 | ||
| $result.CompletionMatches[0].CompletionText | Should Be 'Expression' | ||
| $result.CompletionMatches[1].CompletionText | Should Be 'Ascending' | ||
| $result.CompletionMatches[2].CompletionText | Should Be 'Descending' | ||
| $result.CompletionMatches.Count | Should -Be 3 | ||
| $result.CompletionMatches[0].CompletionText | Should -Be 'Expression' | ||
| $result.CompletionMatches[1].CompletionText | Should -Be 'Ascending' | ||
| $result.CompletionMatches[2].CompletionText | Should -Be 'Descending' | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Similar to above comments. |
||
| } | ||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should be
-BeExactly