Repository navigation
Expand file tree
/
Copy pathtest.sh
More file actions
executable file
·82 lines (70 loc) · 1.86 KB
/
Copy pathtest.sh
File metadata and controls
executable file
·82 lines (70 loc) · 1.86 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
#!/bin/bash
# Quick Compress - Test Suite
# Run this to verify the installation works correctly
set -e
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
TEST_DIR="/tmp/quick-compress-test"
GREEN='\033[0;32m'
RED='\033[0;31m'
NC='\033[0m'
echo "Quick Compress Test Suite"
echo "=========================="
echo ""
# Setup
mkdir -p "$TEST_DIR"
cd "$TEST_DIR"
# Test 1: Check if ImageMagick is installed
echo -n "Test 1: ImageMagick installed... "
if command -v magick >/dev/null 2>&1 || command -v convert >/dev/null 2>&1; then
echo -e "${GREEN}PASS${NC}"
else
echo -e "${RED}FAIL${NC} - ImageMagick not found"
exit 1
fi
# Test 2: Create a test image
echo -n "Test 2: Create test image... "
if command -v magick >/dev/null 2>&1; then
magick -size 100x100 xc:blue test.jpg
else
convert -size 100x100 xc:blue test.jpg
fi
echo -e "${GREEN}PASS${NC}"
# Test 3: Run compression
echo -n "Test 3: Compress single image... "
"$SCRIPT_DIR/compress" test.jpg > /dev/null 2>&1
if [ -f "test.webp" ]; then
echo -e "${GREEN}PASS${NC}"
else
echo -e "${RED}FAIL${NC} - WebP file not created"
exit 1
fi
# Test 4: Verify output format
echo -n "Test 4: Verify WebP format... "
if file test.webp | grep -q "Web/P"; then
echo -e "${GREEN}PASS${NC}"
else
echo -e "${RED}FAIL${NC} - Not a valid WebP file"
exit 1
fi
# Test 5: Test folder processing
echo -n "Test 5: Process folder... "
mkdir -p subfolder
if command -v magick >/dev/null 2>&1; then
magick -size 50x50 xc:red subfolder/test2.png
else
convert -size 50x50 xc:red subfolder/test2.png
fi
"$SCRIPT_DIR/compress" subfolder > /dev/null 2>&1
if [ -f "subfolder/test2.webp" ]; then
echo -e "${GREEN}PASS${NC}"
else
echo -e "${RED}FAIL${NC} - Folder processing failed"
exit 1
fi
# Cleanup
cd /
rm -rf "$TEST_DIR"
echo ""
echo "=========================="
echo -e "${GREEN}All tests passed!${NC}"
echo ""