#!/bin/bash

# Run standalone unit tests in the same manner done by upstream.

set -eux

sed -i 's/# enable-debug-command no/enable-debug-command local/' /etc/valkey/valkey.conf
sed -i 's/# enable-module-command no/enable-module-command local/' /etc/valkey/valkey.conf
sed -i 's/mymaster/valkey-py-test/g' /etc/valkey/sentinel.conf

systemctl restart valkey-server
systemctl restart valkey-sentinel

./util/wait-for-it.sh localhost:6379

# Skip tests requiring modules not in valkey-server package.
IGNORE_MODULE_TESTS="
  --ignore=tests/test_bloom.py
  --ignore=tests/test_json.py
  --ignore=tests/test_search.py
  --ignore=tests/test_timeseries.py
  --ignore=tests/test_asyncio/test_bloom.py
  --ignore=tests/test_asyncio/test_json.py
  --ignore=tests/test_asyncio/test_search.py
  --ignore=tests/test_asyncio/test_timeseries.py
"

for py in $(py3versions --supported)
do
    ${py} -m pytest -W always -m 'onlynoncluster' --sentinels 'localhost:26379' ${IGNORE_MODULE_TESTS}
done
