-
Notifications
You must be signed in to change notification settings - Fork 40
Expand file tree
/
Copy pathtest-message-feature.sh
More file actions
executable file
·122 lines (103 loc) · 3.75 KB
/
test-message-feature.sh
File metadata and controls
executable file
·122 lines (103 loc) · 3.75 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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
#!/bin/bash
# Test script for the new --message feature
echo "Testing Claude Auto-Renewal Custom Message Feature"
echo "=================================================="
echo ""
# Colors for output
GREEN='\033[0;32m'
RED='\033[0;31m'
YELLOW='\033[1;33m'
NC='\033[0m' # No Color
print_test() {
echo -e "${YELLOW}[TEST]${NC} $1"
}
print_success() {
echo -e "${GREEN}[✓]${NC} $1"
}
print_error() {
echo -e "${RED}[✗]${NC} $1"
}
# Test 1: Check that the daemon manager accepts --message parameter
print_test "Testing daemon manager with --message parameter..."
./claude-daemon-manager.sh stop 2>/dev/null
# Start daemon with custom message
./claude-daemon-manager.sh start --message "continue working on the React feature" --disableccusage
# Give it a moment to start
sleep 3
# Check if daemon is running
if ./claude-daemon-manager.sh status | grep -q "running"; then
print_success "Daemon started successfully with --message parameter"
else
print_error "Failed to start daemon with --message parameter"
exit 1
fi
# Test 2: Check if message file was created
MESSAGE_FILE="$HOME/.claude-auto-renew-message"
if [ -f "$MESSAGE_FILE" ]; then
message_content=$(cat "$MESSAGE_FILE")
if [ "$message_content" = "continue working on the React feature" ]; then
print_success "Custom message correctly saved: '$message_content'"
else
print_error "Message content incorrect: '$message_content'"
fi
else
print_error "Message file not created"
fi
# Test 3: Check daemon logs for custom message confirmation
LOG_FILE="$HOME/.claude-auto-renew-daemon.log"
if grep -q "Custom renewal message configured" "$LOG_FILE"; then
print_success "Daemon logged custom message configuration"
else
print_error "Daemon did not log custom message configuration"
fi
# Test 4: Stop and restart without message (should use default)
print_test "Testing daemon restart without --message parameter..."
./claude-daemon-manager.sh stop
sleep 2
./claude-daemon-manager.sh start --disableccusage
sleep 3
if [ -f "$MESSAGE_FILE" ]; then
print_error "Message file still exists after restart without --message"
else
print_success "Message file correctly removed when not using --message"
fi
# Check logs for default message confirmation
if tail -20 "$LOG_FILE" | grep -q "Using default random greeting messages"; then
print_success "Daemon correctly switched to default messages"
else
print_error "Daemon did not log switch to default messages"
fi
# Test 5: Test with different message
print_test "Testing with different custom message..."
./claude-daemon-manager.sh stop
sleep 2
./claude-daemon-manager.sh start --message "please resume our discussion about database optimization" --disableccusage
sleep 3
if [ -f "$MESSAGE_FILE" ]; then
new_message=$(cat "$MESSAGE_FILE")
if [ "$new_message" = "please resume our discussion about database optimization" ]; then
print_success "New custom message correctly saved: '$new_message'"
else
print_error "New message content incorrect: '$new_message'"
fi
else
print_error "Message file not created for new message"
fi
# Cleanup
print_test "Cleaning up..."
./claude-daemon-manager.sh stop
sleep 2
echo ""
echo "=================================================="
echo "Test Summary:"
echo "- Custom message parameter is working correctly"
echo "- Message file is created and removed as expected"
echo "- Daemon properly logs custom message usage"
echo "- Multiple message changes work correctly"
echo ""
print_success "All tests passed! The --message feature is ready to use."
echo ""
echo "Example usage:"
echo " ./claude-daemon-manager.sh start --message \"continue working on the React feature\""
echo " ./claude-daemon-manager.sh start --at \"09:00\" --message \"resume our Python project\""
echo ""