package store

import "testing"

// RoleRank 是 RequireTenantRole 门控的判定核心：阶梯顺序 + billing_admin 与 viewer 同为只读 + 未知记 0。
func TestRoleRank(t *testing.T) {
	if !(RoleRank(RoleOwner) > RoleRank(RoleAdmin) &&
		RoleRank(RoleAdmin) > RoleRank(RoleMember) &&
		RoleRank(RoleMember) > RoleRank(RoleViewer)) {
		t.Fatal("阶梯应为 owner > admin > member > viewer")
	}
	if RoleRank(RoleBillingAdmin) != RoleRank(RoleViewer) {
		t.Errorf("billing_admin 应与 viewer 同为只读级：%d vs %d", RoleRank(RoleBillingAdmin), RoleRank(RoleViewer))
	}
	if RoleRank(RoleBillingAdmin) >= RoleRank(RoleMember) {
		t.Error("billing_admin(财务只读) 不应达到 member 操作级，否则能提交烧积分")
	}
	if RoleRank(RoleViewer) < RoleRank(RoleMember) == false {
		t.Error("viewer 应低于 member（提交任务门控靠此挡下）")
	}
	if RoleRank("") != 0 || RoleRank("nonsense") != 0 {
		t.Error("未知/非成员角色应记 0，一律拦下")
	}
}
