Created
February 14, 2020 17:12
-
-
Save bateskevin/49e3ad5d3af6ab9ddd4caae0be4332ea to your computer and use it in GitHub Desktop.
Running Pester Tests from Module in Linux Containers with Powershell
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Function Invoke-DockerPester { | |
param( | |
$ContainerName = "DockerPester", | |
$Image, | |
$InputFolder, | |
$PathOnContainer = "/var", | |
$PathToTests | |
) | |
if(!($PathToTests)){ | |
$PathToTests = "$(Join-Path $(join-path $PathOnContainer (split-path $InputFolder -Leaf)) "Tests")" | |
} | |
docker run -it -d -t --name $ContainerName $Image | |
$CPString = "$($ContainerName):$($PathOnContainer)" | |
docker cp $InputFolder $CPString | |
docker exec $ContainerName pwsh -command "Install-Module Pester -Force" | |
docker exec $ContainerName pwsh -command "ipmo pester" | |
docker exec $ContainerName pwsh -command "cd $PathToTests" | |
docker exec -it $ContainerName pwsh -command "Invoke-Pester $PathToTests" | |
#docker exec -it $ContainerName pwsh -command "$res | convertto-json" | |
docker rm --force $ContainerName | |
} | |
Invoke-DockerPester -Image "mcr.microsoft.com/powershell:7.0.0-rc.2-alpine-3.10" -InputFolder "/Users/kevin/code/PSHarmonize" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment