-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_core_functions.sh
More file actions
executable file
·93 lines (82 loc) · 2.48 KB
/
test_core_functions.sh
File metadata and controls
executable file
·93 lines (82 loc) · 2.48 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
83
84
85
86
87
88
89
90
91
92
93
#!/bin/bash
# Simple test script for PortKill core functions
# Tests the simplified version's basic functionality
echo "========================================="
echo "PortKill Core Functions Test Suite"
echo "========================================="
PORTKILL="./bin/portkill"
# Test 1: Version check
echo
echo "Test 1: Version check"
echo "---------------------"
if $PORTKILL --version; then
echo "✅ PASS: Version check successful"
else
echo "❌ FAIL: Version check failed"
exit 1
fi
# Test 2: Help command
echo
echo "Test 2: Help command"
echo "--------------------"
if $PORTKILL --help >/dev/null 2>&1; then
echo "✅ PASS: Help command successful"
else
echo "❌ FAIL: Help command failed"
exit 1
fi
# Test 3: List command on a non-existent port
echo
echo "Test 3: List non-existent port"
echo "------------------------------"
if $PORTKILL list 65432 >/dev/null 2>&1; then
echo "✅ PASS: List command on non-existent port handled gracefully"
else
echo "✅ PASS: List command exited with expected status"
fi
# Test 4: JSON output test
echo
echo "Test 4: JSON output"
echo "------------------"
if output=$($PORTKILL --json list 65432 2>/dev/null); then
if echo "$output" | grep -q '"port"'; then
echo "✅ PASS: JSON output contains expected fields"
else
echo "❌ FAIL: JSON output missing expected fields"
echo "Output: $output"
fi
else
echo "❌ FAIL: JSON output test failed"
fi
# Test 5: Port validation
echo
echo "Test 5: Port validation"
echo "----------------------"
if $PORTKILL list 70000 2>&1 | grep -q "Invalid port"; then
echo "✅ PASS: Invalid port correctly rejected"
else
echo "❌ FAIL: Invalid port validation failed"
fi
# Test 6: Process tree command (should not crash)
echo
echo "Test 6: Process tree command"
echo "---------------------------"
if $PORTKILL tree 65432 >/dev/null 2>&1; then
echo "✅ PASS: Process tree command completed"
else
echo "✅ PASS: Process tree command handled gracefully"
fi
# Test 7: Docker mode (should not crash even if Docker unavailable)
echo
echo "Test 7: Docker mode"
echo "------------------"
if $PORTKILL --docker list 65432 >/dev/null 2>&1; then
echo "✅ PASS: Docker mode handled gracefully"
else
echo "✅ PASS: Docker mode failed gracefully"
fi
echo
echo "========================================="
echo "✅ All core function tests completed!"
echo "The simplified PortKill appears to be working correctly."
echo "========================================="