package main // Wiring-level anti-drift test for the shared client enum table (design/07 §6). // The enums package test pins the platform table to the adapters' Name() values; // this one pins it to the composition root's factory — every platform the table // publishes must be one buildAccountAdapter actually knows how to build, so a // phantom entry (a platform listed for clients but never wired up) fails here. import ( "io" "testing" "git.yeij.top/AskaEth/Cyrene_v2/internal/config" "git.yeij.top/AskaEth/Cyrene_v2/internal/contract/enums" "git.yeij.top/AskaEth/Cyrene_v2/internal/logger" "git.yeij.top/AskaEth/Cyrene_v2/internal/runtime/history" ) // TestChannelFactoryBuildsEnumeratedPlatforms builds every adapter the published // platform table lists (other than the Web main-session source, which is not an // adapter) through the real factory and asserts the built adapter's Name() // resolves back to that platform. Adapter construction never dials out, so the // minimal configs below are enough. func TestChannelFactoryBuildsEnumeratedPlatforms(t *testing.T) { t.Parallel() log := logger.New(logger.Options{Out: io.Discard}) minimalConfig := map[string]map[string]any{ "kook": {"bot_token": "test"}, "telegram": {"bot_token": "test"}, } for _, p := range enums.Platforms() { if p.ID == history.PlatformWeb { continue } acct := config.ChannelAccount{Config: minimalConfig[p.ID]} built, err := buildAccountAdapter(p.ID, acct, log) if err != nil { t.Errorf("platform %q is published to clients but the factory cannot build it: %v", p.ID, err) continue } if got := barePlatform(built.Name()); got != p.ID { t.Errorf("buildAccountAdapter(%q).Name() = %q, want %q", p.ID, got, p.ID) } } }