package app import ( "strings" "testing" "hyapp/pkg/roommq" "hyapp/services/activity-service/internal/config" ) func TestRoomOutboxConsumerConfigSerializesCompositeProjection(t *testing.T) { cfg := config.Default().RocketMQ cfg.RoomOutbox.ConsumerGroup = "activity-room-outbox-test" consumerConfig := roomOutboxConsumerConfig(cfg) if consumerConfig.ConsumeGoroutines != 1 { t.Fatalf("room outbox consume goroutines = %d, want 1", consumerConfig.ConsumeGoroutines) } if consumerConfig.GroupName != cfg.RoomOutbox.ConsumerGroup { t.Fatalf("room outbox group = %q, want %q", consumerConfig.GroupName, cfg.RoomOutbox.ConsumerGroup) } } func TestActivityRoomSelectorKeepsLegacyAndOnlyRelevantTypedEvents(t *testing.T) { expression, err := roommq.LegacyCompatibleTagExpression(activityRoomEventTypes()...) if err != nil { t.Fatalf("LegacyCompatibleTagExpression failed: %v", err) } for _, required := range []string{ roommq.TagRoomOutboxEvent, roommq.EventTypeRoomGiftSent, roommq.EventTypeRoomPasswordChanged, roommq.EventTypeRoomRocketIgnited, roommq.EventTypeRoomRocketRewardGranted, } { if !strings.Contains(expression, required) { t.Fatalf("activity room selector %q misses %q", expression, required) } } if strings.Contains(expression, roommq.EventTypeRoomMicChanged) { t.Fatalf("activity room selector must not receive mic events: %q", expression) } } func TestVIPRebateNoticeConsumerDoesNotReplayHistoricalWalletEvents(t *testing.T) { cfg := config.Default().RocketMQ cfg.WalletOutbox.VIPRebateNoticeConsumerGroup = "activity-vip-rebate-notice-test" consumerConfig := walletOutboxVIPRebateNoticeConsumerConfig(cfg) if consumerConfig.ConsumeFromFirst { t.Fatal("VIP rebate notice consumer must start at the latest offset for a new group") } if consumerConfig.GroupName != cfg.WalletOutbox.VIPRebateNoticeConsumerGroup { t.Fatalf("VIP rebate notice group = %q, want %q", consumerConfig.GroupName, cfg.WalletOutbox.VIPRebateNoticeConsumerGroup) } }