Skip to content

Commit

Permalink
Better logic (probably)
Browse files Browse the repository at this point in the history
  • Loading branch information
EliteLoser authored Feb 26, 2018
1 parent 553cb7a commit 59ea083
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions SSHSessions.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ Svendsen Tech.

Import-Module -Name Pester -ErrorAction Stop #-Verbose:$False
$VerbosePreference = "SilentlyContinue"

#$ComputerName = "www.svendsentech.no"
$ComputerName = ""

Expand Down Expand Up @@ -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

}

0 comments on commit 59ea083

Please sign in to comment.