#! /usr/bin/bash DEPENDENCIES=("qbittorrent-nox" "bats" "curl" "grep" "cat" "sed" "ps" "netstat" "envsubst") if [[ "${QBTNOX_DIR:-plz}" = "plz" ]]; then export QBTNOX_DIR="$(mktemp -d)" fi ORIGDIR="$(pwd)" cd "$(dirname "$0")" source ../utils.sh SUBCOMMAND="${1:-test}" if [[ "$SUBCOMMAND" = "test" ]] && [[ "${TESTRUNNER:-plz}" = "plz" ]]; then depsCheck fi export FREEPORT="$(findFreePort)" API="http://localhost:$FREEPORT" # Subcommand is test and checks succeeded subcommand "$SUBCOMMAND" STATUS=$? if [ $STATUS -eq 0 ]; then if [[ "$SUBCOMMAND" = "test" ]]; then cat ../default.toml | envsubst > "$QBTNOX_DIR"/config.toml export CFGFILE="$QBTNOX_DIR"/config.toml if ../qbittorrent-nox.sh start "$QBTNOX_DIR" "$FREEPORT"; then runTests "$API" STATUS=$? ../qbittorrent-nox.sh stop "$QBTNOX_DIR" else echo "qBittorrent did not start" STATUS=1 fi fi fi if [[ "${TESTRUNNER:-plz}" = "plz" ]]; then rm -R "$QBTNOX_DIR" fi cd "$ORIGDIR" exit $STATUS