0
0
Fork 0
mirror of https://github.com/atmoz/sftp.git synced 2024-11-17 12:51:33 -05:00

Test minimal setup as well

This commit is contained in:
Adrian Dvergsdal 2015-12-20 23:45:28 +01:00
parent c388a4ec68
commit c5d2a490ef

View file

@ -1,6 +1,8 @@
#!/bin/bash #!/bin/bash
# See: https://github.com/djui/bashunit # See: https://github.com/djui/bashunit
skipAllTests=false
scriptDir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" scriptDir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
buildDir="$scriptDir/.." buildDir="$scriptDir/.."
tmpDir="/tmp/atmoz_sftp_test" tmpDir="/tmp/atmoz_sftp_test"
@ -75,17 +77,55 @@ function runSftpCommands() {
############################################################################## ##############################################################################
function testMinimalContainerStart() {
$skipAllTests && skip && return 0
tmpContainerName="$sftpContainerName""_minimal"
docker run \
--name "$tmpContainerName" \
-d "$sftpImageName" \
minimal::1111 \
> "$redirect"
sleep 1
ps="$(docker ps -q -f name="$tmpContainerName")"
assertNotEqual "$ps" ""
if [ -z "$ps" ]; then
skipAllTests=true
fi
if [ "$output" != "quiet" ]; then
docker logs "$tmpContainerName"
fi
if [ "$cleanup" == "cleanup" ]; then
docker rm -fv "$tmpContainerName" > "$redirect"
fi
}
function testContainerIsRunning() { function testContainerIsRunning() {
$skipAllTests && skip && return 0
ps="$(docker ps -q -f name="$sftpContainerName")" ps="$(docker ps -q -f name="$sftpContainerName")"
assertNotEqual "$ps" "" assertNotEqual "$ps" ""
if [ -z "$ps" ]; then
skipAllTests=true
fi
} }
function testLoginUsingSshKey() { function testLoginUsingSshKey() {
$skipAllTests && skip && return 0
runSftpCommands "exit" runSftpCommands "exit"
assertReturn $? 0 assertReturn $? 0
} }
function testWritePermission() { function testWritePermission() {
$skipAllTests && skip && return 0
runSftpCommands "cd share" "mkdir test" "exit" runSftpCommands "cd share" "mkdir test" "exit"
test -d "$tmpDir/test" test -d "$tmpDir/test"
assertReturn $? 0 assertReturn $? 0