datasette/tests/test-datasette-load-plugins.sh
Jeroen Van Goey 103b4decbd
fix (typo): Corrected spelling of 'environments' (#2268)
* fix (typo): Corrected spelling of 'environments'

* ci: add test folder to codespell workflow
2024-02-19 14:41:32 -08:00

26 lines
882 B
Bash
Executable file

#!/bin/bash
# This should only run in environments where both
# datasette-init and datasette-json-html are installed
PLUGINS=$(datasette plugins)
if ! echo "$PLUGINS" | jq 'any(.[]; .name == "datasette-json-html")' | grep -q true; then
echo "Test failed: datasette-json-html not found"
exit 1
fi
PLUGINS2=$(DATASETTE_LOAD_PLUGINS=datasette-init datasette plugins)
if ! echo "$PLUGINS2" | jq 'any(.[]; .name == "datasette-json-html")' | grep -q false; then
echo "Test failed: datasette-json-html should not have been loaded"
exit 1
fi
if ! echo "$PLUGINS2" | jq 'any(.[]; .name == "datasette-init")' | grep -q true; then
echo "Test failed: datasette-init should have been loaded"
exit 1
fi
PLUGINS3=$(DATASETTE_LOAD_PLUGINS='' datasette plugins)
if ! echo "$PLUGINS3" | grep -q '\[\]'; then
echo "Test failed: datasette plugins should have returned []"
exit 1
fi