03dfc29a54
CI / changes (pull_request) Successful in 2s
CI / unit (pull_request) Successful in 10s
CI / integration (pull_request) Successful in 18s
CI / ui (pull_request) Successful in 56s
CI / gate (pull_request) Successful in 0s
CI / deploy (pull_request) Successful in 50s
The promo bot button carries a configurable variant-seed start-param (default verudit_ru-scrabble_en). The gateway parses start_param from the validated initData and forwards it; the backend, on first contact only, seeds the new account variant_preferences from it (English Scrabble alongside the default Erudit). No schema change (the scrabble_en CHECK is already in the baseline) and the gateway<->backend REST field is additive, so the rolling deploy is safe in either order. TELEGRAM_PROMO_START_PARAM configures the payload (empty forwards the user own /start payload). Covered by account unit tests, a gateway transcode test, and an integration test asserting new-only seeding.
38 lines
1.4 KiB
Go
38 lines
1.4 KiB
Go
package account
|
|
|
|
import (
|
|
"slices"
|
|
"testing"
|
|
)
|
|
|
|
// TestSeedVariantsFromStartParam covers decoding a promo deep-link start-param into the
|
|
// variant-preference set to seed: a valid "v"-prefixed, "-"-joined label list is cleaned
|
|
// to the canonical order and deduplicated, while anything that is not a variant-seed link
|
|
// or that names an unknown variant yields nil (leaving the account on its defaults).
|
|
func TestSeedVariantsFromStartParam(t *testing.T) {
|
|
tests := []struct {
|
|
name string
|
|
param string
|
|
want []string
|
|
}{
|
|
{"english promo", "verudit_ru-scrabble_en", []string{"erudit_ru", "scrabble_en"}},
|
|
{"single variant", "vscrabble_en", []string{"scrabble_en"}},
|
|
{"canonical order regardless of payload order", "vscrabble_en-erudit_ru", []string{"erudit_ru", "scrabble_en"}},
|
|
{"deduplicated", "verudit_ru-erudit_ru", []string{"erudit_ru"}},
|
|
{"empty", "", nil},
|
|
{"prefix only", "v", nil},
|
|
{"routing game link is not a seed", "g0190abcd", nil},
|
|
{"friend code link is not a seed", "f123456", nil},
|
|
{"unknown variant rejected", "vscrabble_de", nil},
|
|
{"one unknown label rejects the whole set", "verudit_ru-scrabble_de", nil},
|
|
}
|
|
for _, tc := range tests {
|
|
t.Run(tc.name, func(t *testing.T) {
|
|
got := SeedVariantsFromStartParam(tc.param)
|
|
if !slices.Equal(got, tc.want) {
|
|
t.Errorf("SeedVariantsFromStartParam(%q) = %v, want %v", tc.param, got, tc.want)
|
|
}
|
|
})
|
|
}
|
|
}
|