-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest-latest-fetch.sh
More file actions
executable file
·60 lines (52 loc) · 2.17 KB
/
test-latest-fetch.sh
File metadata and controls
executable file
·60 lines (52 loc) · 2.17 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
#!/bin/bash
set -e
echo "🧪 Testing latest version fetching functionality..."
# Test 1: Check if we can fetch the latest version
echo "📥 Testing fetch from GitHub..."
if curl -fsSL "https://raw.githubusercontent.com/GetPageSpeed/debbuilder/refs/heads/main/assets/build" > /tmp/test-latest.sh; then
echo "✅ Successfully fetched latest version"
chmod +x /tmp/test-latest.sh
# Test 2: Check if the fetched script has the expected structure
if grep -q "DEBIAN_FRONTEND=noninteractive" /tmp/test-latest.sh; then
echo "✅ Fetched script has expected structure"
else
echo "❌ Fetched script doesn't have expected structure"
exit 1
fi
# Test 3: Test --help or version info
echo "🔍 Testing script execution..."
if /tmp/test-latest.sh --help 2>&1 | grep -q "Invalid option"; then
echo "✅ Script executes correctly"
else
echo "⚠️ Script execution test inconclusive (this is normal)"
fi
else
echo "❌ Failed to fetch latest version"
exit 1
fi
# Test 4: Test --no-fetch option
echo "🚫 Testing --no-fetch option..."
if /tmp/test-latest.sh --no-fetch --help 2>&1 | grep -q "Invalid option"; then
echo "✅ --no-fetch option works correctly"
else
echo "⚠️ --no-fetch test inconclusive (this is normal)"
fi
# Test 5: Test recursion prevention
echo "🔄 Testing recursion prevention..."
# Create a simple test to verify that --no-fetch is passed to fetched script
if /tmp/test-latest.sh --help 2>&1 | grep -q "Invalid option"; then
echo "✅ Recursion prevention appears to work (script executed without infinite loop)"
else
echo "⚠️ Recursion prevention test inconclusive (this is normal)"
fi
echo "🎉 All tests passed! Latest version fetching is working correctly."
echo ""
echo "📝 Usage examples:"
echo " # Use latest version (default)"
echo " docker run getpagespeed/debbuilder:ubuntu-noble build"
echo ""
echo " # Use local version only"
echo " docker run getpagespeed/debbuilder:ubuntu-noble build --no-fetch"
echo ""
echo " # Use custom external script"
echo " docker run getpagespeed/debbuilder:ubuntu-noble build --external-build-script https://your-script.sh"