mirror of
https://github.com/acedanger/shell.git
synced 2025-12-06 01:10:12 -08:00
Refactor variable assignments and improve script readability in validate-plex-backups.sh and validate-plex-recovery.sh
- Changed inline variable assignments to separate declaration and assignment for clarity. - Updated condition checks and log messages for better readability and consistency. - Added a backup of validate-plex-recovery.sh for safety. - Introduced a new script run-docker-tests.sh for testing setup in Docker containers. - Enhanced ssh-login.sh to improve condition checks and logging functionality.
This commit is contained in:
@@ -8,7 +8,6 @@ set -e
|
||||
# Colors for output
|
||||
RED='\033[0;31m'
|
||||
GREEN='\033[0;32m'
|
||||
YELLOW='\033[0;33m'
|
||||
BLUE='\033[0;34m'
|
||||
NC='\033[0m' # No Color
|
||||
|
||||
@@ -215,7 +214,8 @@ test_env_validation() {
|
||||
log_test "Environment Variable Validation"
|
||||
|
||||
# Temporarily move .env file to test missing env
|
||||
local env_file="$(dirname "$RESTORE_SCRIPT")/../.env"
|
||||
local env_file
|
||||
env_file="$(dirname "$RESTORE_SCRIPT")/../.env"
|
||||
if [ -f "$env_file" ]; then
|
||||
mv "$env_file" "${env_file}.backup"
|
||||
|
||||
@@ -285,11 +285,12 @@ test_logging() {
|
||||
TESTS_RUN=$((TESTS_RUN + 1))
|
||||
log_test "Logging Functionality"
|
||||
|
||||
local log_dir="$(dirname "$RESTORE_SCRIPT")/../logs"
|
||||
local log_dir
|
||||
log_dir="$(dirname "$RESTORE_SCRIPT")/../logs"
|
||||
local restore_log="${log_dir}/immich-restore.log"
|
||||
|
||||
# Clear previous log entries
|
||||
[ -f "$restore_log" ] && > "$restore_log"
|
||||
[ -f "$restore_log" ] && true > "$restore_log"
|
||||
|
||||
local mock_db_backup="${TEST_DIR}/mock_immich_db_backup_20250603_120000.sql.gz"
|
||||
local mock_uploads_backup="${TEST_DIR}/mock_immich_uploads_20250603_120000.tar.gz"
|
||||
@@ -330,10 +331,12 @@ test_performance() {
|
||||
done
|
||||
tar -czf "$large_uploads_backup" -C "${TEST_DIR}" large_mock_uploads
|
||||
|
||||
local start_time=$(date +%s)
|
||||
local start_time
|
||||
start_time=$(date +%s)
|
||||
local output
|
||||
if output=$("$RESTORE_SCRIPT" --db-backup "$large_db_backup" --uploads-backup "$large_uploads_backup" --dry-run 2>&1); then
|
||||
local end_time=$(date +%s)
|
||||
local end_time
|
||||
end_time=$(date +%s)
|
||||
local duration=$((end_time - start_time))
|
||||
|
||||
if [ $duration -lt 30 ]; then # Should complete dry run in under 30 seconds
|
||||
|
||||
Reference in New Issue
Block a user