From 59ea083cb819000daea82c35ffa98d955963cab4 Mon Sep 17 00:00:00 2001 From: Joakim Svendsen Date: Mon, 26 Feb 2018 01:15:23 +0100 Subject: [PATCH] Better logic (probably) --- SSHSessions.Tests.ps1 | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/SSHSessions.Tests.ps1 b/SSHSessions.Tests.ps1 index 43d55c9..f128ee5 100644 --- a/SSHSessions.Tests.ps1 +++ b/SSHSessions.Tests.ps1 @@ -5,6 +5,7 @@ Svendsen Tech. Import-Module -Name Pester -ErrorAction Stop #-Verbose:$False $VerbosePreference = "SilentlyContinue" + #$ComputerName = "www.svendsentech.no" $ComputerName = "" @@ -43,15 +44,20 @@ Describe SshSessions { $Result[0].Result | Should -Be "This is a test" } + It "Remove-SshSession works." { + $Result = (Remove-SshSession -ComputerName $ComputerName -ErrorAction SilentlyContinue -Verbose) 4>&1 + $Result.Message | Should -Match "\[$([Regex]::Escape($ComputerName))\] Now disconnected and disposed" + } + It "The -Reconnect parameter for New-SshSession works." { + $Result = (New-SshSession -ComputerName $ComputerName -Verbose ` + -Credential $Global:PesterSSHSessionsCredentials -ErrorAction Stop) 4>&1 + $Result.Message | Should -Match "\[$([Regex]::Escape($ComputerName))\]\s*(?:Successfully connected|You are already connected)" $Result = (New-SshSession -ComputerName $ComputerName -Reconnect -Credential $Global:PesterSSHSessionsCredentials ` -ErrorAction SilentlyContinue -Verbose) 4>&1 - $Result[2].Message | Should -Match "\[$([Regex]::Escape($ComputerName))\] Successfully connected" + $Result[2].Message | Should -Match "\[$([Regex]::Escape($ComputerName))\]\s*Successfully\s+connected" } - It "Remove-SshSession works." { - $Result = (Remove-SshSession -ComputerName $ComputerName -ErrorAction SilentlyContinue -Verbose) 4>&1 - $Result.Message | Should -Match "\[$([Regex]::Escape($ComputerName))\] Now disconnected and disposed" - } + Get-SshSession | Remove-SshSession }