package config

import "testing"

func TestLoadLocalEnablesOutboxMQConsumers(t *testing.T) {
	cfg, err := Load("../../configs/config.yaml")
	if err != nil {
		t.Fatalf("Load local config failed: %v", err)
	}
	// activity 的充值、红包、礼物和区域播报都依赖 MQ fanout，本地默认必须和测试/线上一致。
	if !cfg.RocketMQ.Enabled || !cfg.RocketMQ.RoomOutbox.Enabled || !cfg.RocketMQ.WalletOutbox.Enabled || !cfg.RocketMQ.UserOutbox.Enabled {
		t.Fatalf("local config must enable all activity outbox MQ consumers: %+v", cfg.RocketMQ)
	}
	if !cfg.FirstRechargeRewardWorker.Enabled || !cfg.CumulativeRechargeRewardWorker.Enabled || !cfg.RedPacketBroadcastWorker.Enabled {
		t.Fatalf("local config must enable wallet outbox workers: first=%+v cumulative=%+v red_packet=%+v", cfg.FirstRechargeRewardWorker, cfg.CumulativeRechargeRewardWorker, cfg.RedPacketBroadcastWorker)
	}
}

func TestLoadTencentExampleEnablesRoomOutboxMQ(t *testing.T) {
	cfg, err := Load("../../configs/config.tencent.example.yaml")
	if err != nil {
		t.Fatalf("Load tencent example failed: %v", err)
	}
	if !cfg.RocketMQ.Enabled || !cfg.RocketMQ.RoomOutbox.Enabled || cfg.RocketMQ.RoomOutbox.Topic == "" || cfg.RocketMQ.RoomOutbox.ConsumerGroup == "" {
		t.Fatalf("tencent example must configure room outbox MQ consumer: %+v", cfg.RocketMQ)
	}
	if !cfg.RocketMQ.UserOutbox.Enabled || cfg.RocketMQ.UserOutbox.Topic != "hyapp_user_outbox" || cfg.RocketMQ.UserOutbox.ConsumerGroup == "" {
		t.Fatalf("tencent example must configure user outbox MQ consumer: %+v", cfg.RocketMQ.UserOutbox)
	}
	if cfg.RocketMQ.WalletOutbox.RealtimeTopic != "hyapp_wallet_realtime_outbox" {
		t.Fatalf("red packet worker should consume realtime wallet topic in tencent example: %+v", cfg.RocketMQ.WalletOutbox)
	}
}
