Implement Pester tests

This commit is contained in:
Maxim Lobanov
2020-07-09 10:53:29 +03:00
parent c6950533af
commit 148b628e0b
19 changed files with 207 additions and 208 deletions

View File

@@ -4,3 +4,5 @@
################################################################################
Choco-Install -PackageName 7zip.install
Invoke-PesterTests -TestFile "Tools" -TestName "7-Zip"

View File

@@ -4,3 +4,5 @@
################################################################################
Choco-Install -PackageName cmake.install -ArgumentList "--installargs",'ADD_CMAKE_TO_PATH=""System""'
Invoke-PesterTests -TestFile "Tools" -TestName "CMake"

View File

@@ -126,3 +126,5 @@ $archivePath = Start-DownloadWithRetry -Url $uri -Name "cobertura.zip"
Extract-7Zip -Path $archivePath -DestinationPath "C:\"
setx COBERTURA_HOME $coberturaPath /M
Invoke-PesterTests -TestFile "Java"

View File

@@ -7,3 +7,5 @@ Choco-Install -PackageName mongodb
$mongoPath = (Get-CimInstance Win32_Service -Filter "Name LIKE 'mongodb'").PathName
$mongoBin = Split-Path -Path $mongoPath.split('"')[1]
Add-MachinePathItem "$mongoBin"
Invoke-PesterTests -TestFile "Databases" -TestName "MongoDB"

View File

@@ -1,15 +0,0 @@
################################################################################
## File: Validate-7zip.ps1
## Desc: Validate 7zip
################################################################################
if (Get-Command -Name '7z')
{
Write-Host '7zip on path'
}
else
{
Write-Host '7zip is not on path'
exit 1
}

View File

@@ -1,16 +0,0 @@
################################################################################
## File: Validate-Cmake.ps1
## Desc: Validate Cmake
################################################################################
if(Get-Command -Name 'cmake')
{
Write-Host "CMake $(cmake -version) on path"
}
else
{
Write-Host "CMake not on path"
exit 1
}

View File

@@ -1,79 +0,0 @@
################################################################################
## File: Validate-JavaTools.ps1
## Desc: Validate various JDKs and java tools
################################################################################
Function Validate-JavaVersion {
param (
[Parameter(Mandatory)] [string] $Version,
[switch] $Default
)
Write-Host "Checking Java $version"
# Set Path to get Java
if (-not $Default)
{
# Take 7 & 8 for versions 1.7 and 1.8
$versionNumber = $version.Split(".") | Select-Object -Last 1
$javaPath = [System.Environment]::GetEnvironmentVariable("JAVA_HOME_${versionNumber}_X64")
if ([string]::IsNullOrEmpty($javaPath))
{
Write-Host "Environment variable 'JAVA_HOME_${versionNumber}_X64' is null"
exit 1
}
$javaBin = "$javaPath\bin;"
$env:Path = $javaBin + $env:Path
}
else
{
Validate-JavaVersion -Version $Version
}
$isJavaExists = $($(& $env:comspec "/s /c java -version 2>&1") | Out-String) -match '^(?<vendor>.+) version "(?<version>.+)".*'
if ($isJavaExists)
{
$javaVersion = $matches.version
}
else
{
Write-Host "Java $version was not found"
exit 1
}
$isJavaCorrect = $javaVersion.StartsWith($version)
if($isJavaCorrect)
{
Write-Host "Java $javaVersion found"
# Reset Path to the default one in case we need to check the default Java later
$env:Path = [System.Environment]::GetEnvironmentVariable("Path","Machine") + ";" + [System.Environment]::GetEnvironmentVariable("Path","User")
}
else
{
Write-Host "Expected Java $version, but found $javaVersion"
exit 1
}
}
if((Get-Command -Name 'java') -and (Get-Command -Name 'mvn') -and (Get-Command -Name 'ant') -and (Get-Command -Name 'gradle'))
{
Write-Host "Java $(java -version) on path"
Write-Host "Maven $(mvn -version) on path"
Write-Host "Ant $(ant -version) on path"
Write-Host "Gradle $(gradle -version) on path"
}
else
{
Write-Host "one of Java,Maven,Ant,Gradle is not on path."
exit 1
}
Write-Host "Checking installed Java versions"
Validate-JavaVersion -Version "1.7"
Validate-JavaVersion -Version "1.8" -Default
Validate-JavaVersion -Version "11"
Validate-JavaVersion -Version "13"

View File

@@ -1,14 +0,0 @@
################################################################################
## File: Validate-Kind.ps1
## Desc: Validate Kind.
################################################################################
if (Get-Command -Name 'kind')
{
Write-Host "kind $(kind version) in path"
}
else
{
Write-Host "kind is not in path"
exit 1
}

View File

@@ -1,24 +0,0 @@
################################################################################
## File: Validate-MongoDB.ps1
## Desc: Validate MongoDB
################################################################################
if (Get-Command -Name 'mongod')
{
Write-Host 'mongod is on path'
}
else
{
Write-Host 'mongod not on path'
exit 1
}
if (Get-Command -Name 'mongo')
{
Write-Host 'mongo is on path'
}
else
{
Write-Host 'mongo not on path'
exit 1
}

View File

@@ -41,6 +41,8 @@ Install-PackageProvider -Name NuGet -MinimumVersion 2.8.5.201 -Force
Install-Module -Name PowerShellGet -Force
Set-PSRepository -InstallationPolicy Trusted -Name PSGallery
Write-Host "Install the latest Pester version"
Install-Module Pester -Scope AllUsers -SkipPublisherCheck -Force
Write-Host "Disable Antivirus"
Set-MpPreference -DisableRealtimeMonitoring $true

View File

@@ -38,6 +38,8 @@ Install-PackageProvider -Name NuGet -MinimumVersion 2.8.5.201 -Force
Install-Module -Name PowerShellGet -Force
Set-PSRepository -InstallationPolicy Trusted -Name PSGallery
Write-Host "Install the latest Pester version"
Install-Module Pester -Scope AllUsers -SkipPublisherCheck -Force
Write-Host "Disable Antivirus"
Set-MpPreference -DisableRealtimeMonitoring $true