Skip to content

Commit

Permalink
Merge pull request #220 from StefanScherer/improve-node-tests
Browse files Browse the repository at this point in the history
Improve Node.js tests running commands in container
  • Loading branch information
StefanScherer authored Oct 31, 2017
2 parents 3e320d2 + ca0fe47 commit a28f164
Showing 1 changed file with 21 additions and 7 deletions.
28 changes: 21 additions & 7 deletions node/test.ps1
Original file line number Diff line number Diff line change
@@ -1,12 +1,26 @@
function testVersion($majorMinorPatch) {
docker run node:$majorMinorPatch-windowsservercore node --version
$ErrorActionPreference = 'SilentlyContinue';
docker run node:$majorMinorPatch-windowsservercore npm.cmd --version
$ErrorActionPreference = 'Stop';
docker run node:$majorMinorPatch-nanoserver node --version
function testCommand($image, $command, $expected) {
Write-Host "Testing: docker run $image $command --version"
$ErrorActionPreference = 'SilentlyContinue';
docker run node:$majorMinorPatch-nanoserver npm.cmd --version
$actual = $(docker run $image $command --version)
$ErrorActionPreference = 'Stop';
Write-Host $actual
if ($LastExitCode) {
Write-Error "Command exited with error $LastExitCode"
}
if ($expected -and ($actual -ne $expected)) {
Write-Error "Expected '$expected', but got '$actual'"
}
if ($actual -eq "") {
Write-Error "Expected some output, but got '$actual'"
}
}

function testVersion($majorMinorPatch) {
testCommand "node:$majorMinorPatch-windowsservercore" "node" "v$majorMinorPatch"
testCommand "node:$majorMinorPatch-windowsservercore" "npm.cmd" ""

testCommand "node:$majorMinorPatch-nanoserver" "node" "v$majorMinorPatch"
testCommand "node:$majorMinorPatch-nanoserver" "npm.cmd" ""
}

testVersion "6.11.5"
Expand Down

0 comments on commit a28f164

Please sign in to comment.