Files
Rogeeandrogee f36606a4f2 HH-564: harden durable realtime publish boundaries (#139)
* fix(HH-564): harden durable realtime enqueue

* fix(HH-564): wire production SSE stream

---------

Co-authored-by: Rogee <rogee@ipao.vip>
2026-08-23 23:38:00 +08:00

31 lines
1.0 KiB
Go

package v1
import (
"os"
"path/filepath"
"testing"
"github.com/stretchr/testify/require"
"github.com/gochat/gochat/internal/worker"
"github.com/gochat/gochat/internal/ws"
applogger "github.com/gochat/gochat/pkg/logger"
)
func TestPublishRealtimeEventLogsEnqueueFailure(t *testing.T) {
logPath := filepath.Join(t.TempDir(), "realtime.log")
require.NoError(t, applogger.Init(applogger.Config{Level: "error", Format: "console", Output: logPath, ErrorOutput: logPath}))
t.Cleanup(func() {
require.NoError(t, applogger.Init(applogger.Config{Level: "info", Format: "console", Output: "stdout", ErrorOutput: "stderr"}))
})
publisher := ws.NewEventPublisherLocal(nil, nil)
publisher.SetWorkerPool(worker.NewWorkerPool(nil))
publishRealtimeEvent(publisher, 42, ws.EventContactUpdated, map[string]any{"id": 7})
applogger.Sync()
logs, err := os.ReadFile(logPath)
require.NoError(t, err)
require.Contains(t, string(logs), "publish realtime event contact.updated for account 42: worker database is required")
}