45 lines
1.0 KiB
Go
45 lines
1.0 KiB
Go
package luckygift
|
|
|
|
import (
|
|
"testing"
|
|
|
|
domain "hyapp/services/activity-service/internal/domain/luckygift"
|
|
)
|
|
|
|
func TestDefaultConfigPassesValidation(t *testing.T) {
|
|
config := DefaultConfig("hyapp")
|
|
config.Enabled = true
|
|
|
|
if err := validateConfig(config); err != nil {
|
|
t.Fatalf("default lucky gift config should be publishable: %v", err)
|
|
}
|
|
}
|
|
|
|
func TestValidateConfigRejectsGiftScopedRules(t *testing.T) {
|
|
config := DefaultConfig("hyapp")
|
|
config.GiftID = "gift_500"
|
|
|
|
if err := validateConfig(config); err == nil {
|
|
t.Fatalf("expected gift scoped lucky gift config to be rejected")
|
|
}
|
|
}
|
|
|
|
func TestNormalizeTiersPreservesDisabledOperationalTiers(t *testing.T) {
|
|
tiers := normalizeTiers([]domain.Tier{
|
|
{
|
|
Pool: domain.PoolAdvanced,
|
|
TierID: "adv_jackpot_500x",
|
|
RewardCoins: 250_000,
|
|
Weight: 1_000,
|
|
Enabled: false,
|
|
},
|
|
}, 500)
|
|
|
|
if len(tiers) != 1 {
|
|
t.Fatalf("expected one normalized tier, got %d", len(tiers))
|
|
}
|
|
if tiers[0].Enabled {
|
|
t.Fatalf("disabled tier was re-enabled during normalization")
|
|
}
|
|
}
|