File: test/

Recommend this page to a friend!
  Classes of Dom Hastings  >  JS Webdav Client  >  test/  >  Download  
File: test/
Role: Auxiliary data
Content type: text/plain
Description: Auxiliary data
Class: JS Webdav Client
Access files of a Webdav server
Author: By
Last change: Adding in additional test files for the Docker test environment
Fixed font test code
Removed duplicate call to _sortFiles()
Noticed a bug in that clicking on source.js in the new set up reloads the page, need to work out why I think it's evaling the code but I don't understand why...
Date: 2 years ago
Size: 2,221 bytes


Class file image Download

dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null && pwd )";

if [ "$(docker ps -a | grep webdav-js-app)" ]; then
    docker stop webdav-js-app > /dev/null;
    docker rm webdav-js-app > /dev/null;

# additional test files
tmpDir=$(cd "$dir/../tmp" && pwd);
if [[ ! -d $tmpDir ]]; then
    mkdir $tmpDir;

volumes="-v $dir/../:/var/www/webdav-js:ro -v $dir/../examples/apache-directory-list/webdav.conf:/etc/apache2/sites-enabled/webdav.conf:ro -v $dir/../src/webdav.js:/var/www/html/source.js:ro -v $dir/../assets/css/style.css:/var/www/html/style.css:ro";

# Hide missing ServerName error
if [[ ! -e $tmpDir/server.conf ]]; then
    echo 'ServerName localhost' > $tmpDir/server.conf;

volumes="$volumes -v $tmpDir/server.conf:/etc/apache2/sites-enabled/server.conf:ro";

# get random images for testing
echo -n "Downloading images... ";

for (( i = 0; i < 10; i++ )); do
    if [[ ! -e "$tmpDir/$i.jpg" ]]; then
        curl -sL -o "$tmpDir/$i.jpg" "";

    volumes="$volumes -v $tmpDir/$i.jpg:/var/www/html/image_$i.jpg:ro";

echo 'Done!';

# get fonts for testing
echo -n "Downloading fonts... ";

for font in notoserif/NotoSerif-Regular.ttf unlock/Unlock-Regular.ttf blackandwhitepicture/BlackAndWhitePicture-Regular.ttf indieflower/IndieFlower-Regular.ttf; do
    fontName="$(basename $font)";

    if [[ ! -e "$tmpDir/$fontName" ]]; then
        curl -s -o "$tmpDir/$fontName" "$font";

    volumes="$volumes -v $tmpDir/$fontName:/var/www/html/$fontName:ro";

echo 'Done!';

# get video for testing
echo -n "Downloading video... ";

if [[ ! -e "$tmpDir/video.mp4" ]]; then
    curl -s -o "$tmpDir/video.mp4" "";

volumes="$volumes -v $tmpDir/video.mp4:/var/www/html/video.mp4:ro";
echo 'Done!';

docker run -dit \
--name webdav-js-app \
-p 8080:80 \
$volumes \
webdav-js sleep infinity;

docker exec -it webdav-js-app /bin/bash -c "\
chown www-data -R /var/www/html 2> /dev/null; \
rm /etc/apache2/sites-enabled/000-default.conf; \
apachectl start || apachectl restart \

echo 'This can be tested on http://localhost:8080';