tests: Add a check.sh test script for transferwee - transferwee - Download/upload file via wetransfer.com
(HTM) git clone https://github.com/iamleot/transferwee
(DIR) Log
(DIR) Files
(DIR) Refs
(DIR) README
---
(DIR) commit 6af0b64011f941cd9ca77419d3f199534eb07932
(DIR) parent 5ae4f014ce753dfbdc90c36b92bab2a65f0cb9ff
(HTM) Author: Leonardo Taccari <iamleot@gmail.com>
Date: Sun, 30 Dec 2018 18:24:45 +0100
tests: Add a check.sh test script for transferwee
check.sh tests transferwee by uploading a test file, downloading
it and then comparing the uploded one and downloaded one via cmp(1)
to check if they are the same.
Diffstat:
A tests/check.sh | 39 +++++++++++++++++++++++++++++++
1 file changed, 39 insertions(+), 0 deletions(-)
---
(DIR) diff --git a/tests/check.sh b/tests/check.sh
@@ -0,0 +1,39 @@
+#!/bin/sh
+
+#
+# Test transferwee by uploading and then downloading a test file.
+#
+# To run this test, just invoke:
+# % ./check.sh
+#
+
+TRANSFERWEE=$(readlink -f ../transferwee.py)
+
+set -e
+
+testtmpdir=$(mktemp -d '/tmp/transferwee_test_XXXXXX')
+testtmpfile=hello
+
+cd "${testtmpdir}"
+
+echo "Creating a test file..."
+echo "Hello world!" > "${testtmpfile}"
+
+echo "Uploading the test file..."
+url=$(${TRANSFERWEE} upload -m 'Just a text file with the mandatory message...' "${testtmpfile}")
+echo "test file uploaded as ${url}"
+
+echo "Renaming original test file..."
+mv "${testtmpfile}" "${testtmpfile}.orig"
+
+echo "Waiting 5 seconds before downloading the file..."
+sleep 5
+
+echo "Downloading the test file via ${url}..."
+${TRANSFERWEE} download "${url}"
+
+echo "Checking if the uploaded file and downloaded file are the same..."
+cmp "${testtmpfile}.orig" "${testtmpfile}"
+
+cd "${OLDPWD}"
+rm -rf "${testtmpdir}"