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") }