package host import "testing" func TestResolveRoleScopePolicyKeepsAppDifferencesInRegistry(t *testing.T) { tests := []struct { name string appCode string baseScope RoleScope configurable bool expanded RoleScope }{ {name: "default app", appCode: "lalu", baseScope: RoleScopeCountry, configurable: true, expanded: RoleScopeRegion}, {name: "normalized huwaa", appCode: " HUWAa ", baseScope: RoleScopeGlobal, configurable: false, expanded: RoleScopeGlobal}, } for _, testCase := range tests { t.Run(testCase.name, func(t *testing.T) { policy, err := ResolveRoleScopePolicy(testCase.appCode, RoleScopeSceneManagerOperations) if err != nil { t.Fatalf("resolve policy: %v", err) } if policy.BaseScope != testCase.baseScope || policy.RegionExpansionConfigurable != testCase.configurable { t.Fatalf("policy mismatch: %+v", policy) } if got := policy.EffectiveScope(true); got != testCase.expanded { t.Fatalf("expanded scope = %q, want %q", got, testCase.expanded) } }) } } func TestResolveRoleScopePolicyKeepsLegacyManagerSceneCompatible(t *testing.T) { policy, err := ResolveRoleScopePolicy("lalu", RoleScopeSceneManagerAddBDLeader) if err != nil { t.Fatalf("resolve legacy manager scene: %v", err) } if policy.Scene != RoleScopeSceneManagerOperations || policy.ExpandedScope != RoleScopeRegion { t.Fatalf("legacy scene must resolve to general manager policy: %+v", policy) } }