Skip to content

Commit 6280f1a

Browse files
committed
Refactor logging in collaboration WebSocket handler for improved readability and add server test runner script to automate server-side testing.
1 parent c62ef8d commit 6280f1a

File tree

2 files changed

+42
-2
lines changed

2 files changed

+42
-2
lines changed

excalidraw-server/handlers/websocket/collab.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ func SetupSocketIO() *socketio.Server {
4040
me := socket.Id()
4141
myRoom := socketio.Room(me)
4242
ioo.To(myRoom).Emit("init-room")
43-
utils.Log().Println("init room ", myRoom)
43+
utils.Log().Printf("init room %v\n", myRoom)
4444

4545
socket.On("join-room", func(datas ...any) {
4646
room := socketio.Room(datas[0].(string))
@@ -65,7 +65,7 @@ func SetupSocketIO() *socketio.Server {
6565
for _, user := range usersInRoom {
6666
newRoomUsers = append(newRoomUsers, user.Id())
6767
}
68-
utils.Log().Println(" room ", room, " has users ", newRoomUsers)
68+
utils.Log().Printf("room %v has users %v\n", room, newRoomUsers)
6969
ioo.In(room).Emit(
7070
"room-user-change",
7171
newRoomUsers,

tests/server/run.sh

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
#!/bin/bash
2+
3+
# Server Test Runner Script
4+
# This script runs all server-side tests for the Excalidraw server
5+
6+
set -e # Exit on error
7+
set -u # Exit on undefined variable
8+
9+
echo "========================================="
10+
echo "Running Excalidraw Server Tests"
11+
echo "========================================="
12+
echo ""
13+
14+
# Change to the excalidraw-server directory
15+
cd "$(dirname "$0")/../../excalidraw-server" || exit 1
16+
17+
echo "📦 Downloading Go dependencies..."
18+
go mod download || {
19+
echo "❌ Failed to download dependencies"
20+
exit 1
21+
}
22+
23+
echo ""
24+
echo "🧪 Running tests..."
25+
echo ""
26+
27+
# Run Go tests with verbose output
28+
go test -v ./... || {
29+
echo ""
30+
echo "❌ Tests failed!"
31+
exit 1
32+
}
33+
34+
echo ""
35+
echo "========================================="
36+
echo "✅ All server tests passed!"
37+
echo "========================================="
38+
39+
exit 0
40+

0 commit comments

Comments
 (0)