test-datasette-load-plugins now fails correctly, refs #2193

This commit is contained in:
Simon Willison 2023-09-21 12:55:50 -07:00
commit 80a9cd9620

View file

@ -3,27 +3,24 @@
# datasette-init and datasette-json-html are installed # datasette-init and datasette-json-html are installed
PLUGINS=$(datasette plugins) PLUGINS=$(datasette plugins)
echo "$PLUGINS" | jq 'any(.[]; .name == "datasette-json-html")' | \ if ! echo "$PLUGINS" | jq 'any(.[]; .name == "datasette-json-html")' | grep -q true; then
grep -q true || ( \ echo "Test failed: datasette-json-html not found"
echo "Test failed: datasette-json-html not found" && \ exit 1
exit 1 \ fi
)
# With the DATASETTE_LOAD_PLUGINS we should not see that
PLUGINS2=$(DATASETTE_LOAD_PLUGINS=datasette-init datasette plugins) PLUGINS2=$(DATASETTE_LOAD_PLUGINS=datasette-init datasette plugins)
echo "$PLUGINS2" | jq 'any(.[]; .name == "datasette-json-html")' | \ if ! echo "$PLUGINS2" | jq 'any(.[]; .name == "datasette-json-html")' | grep -q false; then
grep -q false || ( \ echo "Test failed: datasette-json-html should not have been loaded"
echo "Test failed: datasette-json-html should not have been loaded" && \ exit 1
exit 1 \ fi
)
echo "$PLUGINS2" | jq 'any(.[]; .name == "datasette-init")' | \ if ! echo "$PLUGINS2" | jq 'any(.[]; .name == "datasette-init")' | grep -q true; then
grep -q true || ( \ echo "Test failed: datasette-init should have been loaded"
echo "Test failed: datasette-init should have been loaded" && \ exit 1
exit 1 \ fi
)
# With DATASETTE_LOAD_PLUGINS='' we should see no plugins
PLUGINS3=$(DATASETTE_LOAD_PLUGINS='' datasette plugins) PLUGINS3=$(DATASETTE_LOAD_PLUGINS='' datasette plugins)
echo "$PLUGINS3"| \ if ! echo "$PLUGINS3" | grep -q '\[\]'; then
grep -q '\[\]' || ( \ echo "Test failed: datasette plugins should have returned []"
echo "Test failed: datasette plugins should have returned []" && \ exit 1
exit 1 \ fi
)