|
|
|
@ -3,6 +3,7 @@ package events
|
|
|
|
// Tests for event base fields and event type string behavior.
|
|
|
|
// Tests for event base fields and event type string behavior.
|
|
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
import (
|
|
|
|
|
|
|
|
"context"
|
|
|
|
"testing"
|
|
|
|
"testing"
|
|
|
|
"time"
|
|
|
|
"time"
|
|
|
|
|
|
|
|
|
|
|
|
@ -26,3 +27,39 @@ func TestNewBaseEvent(t *testing.T) {
|
|
|
|
func TestEventType_String(t *testing.T) {
|
|
|
|
func TestEventType_String(t *testing.T) {
|
|
|
|
require.Equal(t, "game_session.started", GameSessionStarted.String())
|
|
|
|
require.Equal(t, "game_session.started", GameSessionStarted.String())
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// TestEventType_NonEmpty ensures all event type constants are non-empty strings.
|
|
|
|
|
|
|
|
func TestEventType_NonEmpty(t *testing.T) {
|
|
|
|
|
|
|
|
types := []EventType{
|
|
|
|
|
|
|
|
GameSessionStarted,
|
|
|
|
|
|
|
|
GameSessionEnded,
|
|
|
|
|
|
|
|
GameSessionTimedOut,
|
|
|
|
|
|
|
|
AnswerSubmitted,
|
|
|
|
|
|
|
|
HintRequested,
|
|
|
|
|
|
|
|
QuestionAnswered,
|
|
|
|
|
|
|
|
UserRegistered,
|
|
|
|
|
|
|
|
UserEmailVerified,
|
|
|
|
|
|
|
|
UserDeleted,
|
|
|
|
|
|
|
|
QuestionCreated,
|
|
|
|
|
|
|
|
QuestionUpdated,
|
|
|
|
|
|
|
|
QuestionDeleted,
|
|
|
|
|
|
|
|
ScoreUpdated,
|
|
|
|
|
|
|
|
LeaderboardRefreshed,
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for _, eventType := range types {
|
|
|
|
|
|
|
|
require.NotEmpty(t, eventType.String())
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
type dummyEventBus struct{}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func (d *dummyEventBus) Publish(_ context.Context, _ Event) error {
|
|
|
|
|
|
|
|
return nil
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func (d *dummyEventBus) Subscribe(_ EventHandler) error {
|
|
|
|
|
|
|
|
return nil
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var _ EventBus = (*dummyEventBus)(nil)
|
|
|
|
|