forked from EvotecIT/PSBlackListChecker
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPSBlackListChecker.Tests.ps1
31 lines (25 loc) · 1.21 KB
/
PSBlackListChecker.Tests.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
param (
$TeamsID = $Env:TEAMSPESTERID,
$SlackID = $Env:SLACKPESTERID,
$DiscordID = $Env:DISCORDURL
)
$PSVersionTable.PSVersion
$ModuleName = (Get-ChildItem $PSScriptRoot\*.psd1).BaseName
$Pester = (Get-Module -ListAvailable pester)
if ($null -eq $Pester -or ($Pester[0].Version.Major -le 4 -and $Pester[0].Version.Minor -lt 4)) {
Write-Warning "$ModuleName - Downloading Pester from PSGallery"
Install-Module -Name Pester -Repository PSGallery -Force -SkipPublisherCheck -Scope CurrentUser
}
$RequiredModules = (Get-Content -Raw $PSScriptRoot\*.psd1) | Invoke-Expression | ForEach-Object RequiredModules
foreach ($Module in $RequiredModules) {
$ModuleFound = Get-Module -ListAvailable $Module
if ($null -eq $ModuleFound) {
Write-Warning "$ModuleName - Downloading $Module from PSGallery"
Install-Module -Name $Module -Repository PSGallery -Force -Scope CurrentUser
}
}
Import-Module $PSScriptRoot\PSBlackListChecker.psd1 -Force #-Verbose
$result = Invoke-Pester -Script @{ Path = "$($PSScriptRoot)\Tests"; Parameters = @{ TeamsID = $TeamsID; SlackID = $SlackID; DiscordID = $DiscordID } } -EnableExit
if ($result.FailedCount -gt 0) {
throw "$($result.FailedCount) tests failed."
}