Update Generic Tests
This commit is contained in:
@@ -1,23 +1,39 @@
|
||||
$moduleName = "ZertoApiWrapper"
|
||||
$moduleFileName = "ZertoApiWrapper.psm1"
|
||||
$filePath = (Split-Path -Parent $MyInvocation.MyCommand.Path) -replace 'Tests', 'ZertoApiWrapper'
|
||||
$fileName = (Split-Path -Leaf $MyInvocation.MyCommand.Path ) -replace '.Tests.', '.'
|
||||
$docsPath = (Split-Path -Parent $MyInvocation.MyCommand.Path) -replace 'Tests[\\\/]Public', 'docs'
|
||||
$modulePath = $filePath -replace "Public", ""
|
||||
Import-Module $modulePath\$moduleFileName -Force
|
||||
|
||||
$userName = "zerto\build"
|
||||
$password = ConvertTo-SecureString -String "ZertoBuild" -AsPlainText -Force
|
||||
$credential = New-Object -TypeName System.Management.Automation.PSCredential($userName, $password)
|
||||
|
||||
# $credential = Import-Clixml -Path C:\ZertoScripts\Creds.xml
|
||||
$zertoServer = "192.168.1.100"
|
||||
$zertoPort = "7669"
|
||||
Import-Module $modulePath\$moduleFileName
|
||||
|
||||
Describe "File Tests" {
|
||||
$commands = Get-Command -Module ZertoApiWrapper | Select-Object -ExpandProperty Name
|
||||
Remove-Module $moduleName -Force
|
||||
Import-Module $modulePath\$moduleFileName
|
||||
$commands = Get-Command -Module $moduleName | Select-Object -ExpandProperty Name
|
||||
foreach ($command in $commands) {
|
||||
$externalHelpFile = "{0}/{1}.md" -f $docsPath, $command
|
||||
$path = "{0}/{1}.ps1" -f $filePath, $command
|
||||
it "$command is backed by a file with the same name" {
|
||||
$path | should exist
|
||||
context "$command File Tests" {
|
||||
it "$command is backed by a file with the same name" {
|
||||
$path | should exist
|
||||
}
|
||||
it "$command file has openbraces on the same line as the statement" {
|
||||
$content = Get-Content -Path $path
|
||||
$openingBracesExist = $content | Where-Object {$_.Trim() -eq '{'}
|
||||
if ($openingBracesExist) {
|
||||
Write-Warning "Found the following opening brances on their own line:"
|
||||
foreach ($openingBrace in $openingBracesExist) {
|
||||
Write-Warning "Opening Brace on it's own line - $openingBrace"
|
||||
}
|
||||
}
|
||||
$openingBracesExist | should benullorempty
|
||||
}
|
||||
it "$command has an external help file" {
|
||||
$externalHelpFile | should exist
|
||||
}
|
||||
it "$command has the External Help File Defined" {
|
||||
Get-Content -Path $path -First 1 | should be "<# .ExternalHelp ./en-us/ZertoApiWrapper-help.xml #>"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user