Refactoring & tests
This commit is contained in:
Executable
+60
@@ -0,0 +1,60 @@
|
||||
#!/bin/bash
|
||||
# Test-Runner für Logseq-Installer Tests
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
TEST_DIR="${SCRIPT_DIR}/test"
|
||||
|
||||
# Farben
|
||||
RED='\033[0;31m'
|
||||
GREEN='\033[0;32m'
|
||||
YELLOW='\033[1;33m'
|
||||
NC='\033[0m' # No Color
|
||||
|
||||
echo -e "${GREEN}========================================${NC}"
|
||||
echo -e "${GREEN} Logseq-Installer Test Suite${NC}"
|
||||
echo -e "${GREEN}========================================${NC}"
|
||||
echo
|
||||
|
||||
# Prüfen ob bats installiert ist
|
||||
if ! command -v bats &> /dev/null; then
|
||||
echo -e "${RED}Fehler: bats (Bash Automated Testing System) ist nicht installiert.${NC}"
|
||||
echo "Installation: sudo apt-get install bats # Debian/Ubuntu"
|
||||
echo " sudo dnf install bats # Fedora"
|
||||
echo " brew install bats-core # macOS"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Mocks ausführbar machen
|
||||
chmod +x "${TEST_DIR}/mocks/"*
|
||||
|
||||
# Test-Fixtures prüfen
|
||||
if [[ ! -f "${TEST_DIR}/fixtures/Logseq-linux-x64-0.10.15.AppImage" ]]; then
|
||||
echo -e "${YELLOW}Erstelle Test-Fixtures...${NC}"
|
||||
for ver in 0.10.14 0.10.15 0.10.16; do
|
||||
{
|
||||
echo "#!/bin/bash"
|
||||
echo "echo \"Logseq ${ver} dummy\""
|
||||
} > "${TEST_DIR}/fixtures/Logseq-linux-x64-${ver}.AppImage"
|
||||
chmod +x "${TEST_DIR}/fixtures/Logseq-linux-x64-${ver}.AppImage"
|
||||
done
|
||||
fi
|
||||
|
||||
echo -e "${YELLOW}Führe Tests aus...${NC}"
|
||||
echo
|
||||
|
||||
# Bats ausführen
|
||||
if bats "${TEST_DIR}/logseq-installer.bats"; then
|
||||
echo
|
||||
echo -e "${GREEN}========================================${NC}"
|
||||
echo -e "${GREEN} Alle Tests erfolgreich!${NC}"
|
||||
echo -e "${GREEN}========================================${NC}"
|
||||
exit 0
|
||||
else
|
||||
echo
|
||||
echo -e "${RED}========================================${NC}"
|
||||
echo -e "${RED} Einige Tests fehlgeschlagen${NC}"
|
||||
echo -e "${RED}========================================${NC}"
|
||||
exit 1
|
||||
fi
|
||||
Reference in New Issue
Block a user