added subscription.Message.WriteSSE method

This commit is contained in:
Gani Georgiev
2025-02-21 13:04:23 +02:00
parent 973916bb48
commit 4db497c5e1
6 changed files with 3481 additions and 3409 deletions

View File

@@ -0,0 +1,25 @@
package subscriptions_test
import (
"strings"
"testing"
"github.com/pocketbase/pocketbase/tools/subscriptions"
)
func TestMessageWrite(t *testing.T) {
m := subscriptions.Message{
Name: "test_name",
Data: []byte("test_data"),
}
var sb strings.Builder
m.WriteSSE(&sb, "test_id")
expected := "id:test_id\nevent:test_name\ndata:test_data\n\n"
if v := sb.String(); v != expected {
t.Fatalf("Expected writer content\n%q\ngot\n%q", expected, v)
}
}