feat(lns): add catalog presence aliases

This commit is contained in:
Virgil 2026-04-04 07:26:31 +00:00
parent 9971d4f33b
commit 95d083bee0
3 changed files with 80 additions and 0 deletions

56
lns.go
View file

@ -2624,6 +2624,20 @@ func (s *Service) GetDefaultReservedCatalog() *covenant.ReservedCatalog {
return s.DefaultReservedCatalog()
}
// HasReservedCatalog reports whether the service has a reserved-name catalog.
//
// ok := svc.HasReservedCatalog()
func (s *Service) HasReservedCatalog() bool {
return s.ReservedCatalog() != nil
}
// GetHasReservedCatalog is an alias for HasReservedCatalog.
//
// ok := svc.GetHasReservedCatalog()
func (s *Service) GetHasReservedCatalog() bool {
return s.HasReservedCatalog()
}
// DefaultReservedCatalog exposes the reserved-name catalog used by LNS.
//
// This returns the canonical covenant-backed catalog, independent of the
@ -2820,6 +2834,20 @@ func (s *Service) GetLockedCatalog() *covenant.LockedCatalog {
return s.LockedCatalog()
}
// HasLockedCatalog reports whether the service has a locked-name catalog.
//
// ok := svc.HasLockedCatalog()
func (s *Service) HasLockedCatalog() bool {
return s.LockedCatalog() != nil
}
// GetHasLockedCatalog is an alias for HasLockedCatalog.
//
// ok := svc.GetHasLockedCatalog()
func (s *Service) GetHasLockedCatalog() bool {
return s.HasLockedCatalog()
}
// DefaultLockedCatalog returns the package default locked-name catalog.
//
// This ignores any service-specific override so callers can always recover
@ -2854,6 +2882,34 @@ func GetLockedCatalog() *covenant.LockedCatalog {
return DefaultLockedCatalog()
}
// HasReservedCatalog reports whether the package has a reserved-name catalog.
//
// ok := lns.HasReservedCatalog()
func HasReservedCatalog() bool {
return ReservedCatalog() != nil
}
// GetHasReservedCatalog is an alias for HasReservedCatalog.
//
// ok := lns.GetHasReservedCatalog()
func GetHasReservedCatalog() bool {
return HasReservedCatalog()
}
// HasLockedCatalog reports whether the package has a locked-name catalog.
//
// ok := lns.HasLockedCatalog()
func HasLockedCatalog() bool {
return LockedCatalog() != nil
}
// GetHasLockedCatalog is an alias for HasLockedCatalog.
//
// ok := lns.GetHasLockedCatalog()
func GetHasLockedCatalog() bool {
return HasLockedCatalog()
}
// GetDefaultLockedCatalog is an alias for DefaultLockedCatalog.
//
// catalog := lns.GetDefaultLockedCatalog()

View file

@ -444,6 +444,14 @@ func TestPackageDefaultCatalogAliases(t *testing.T) {
if GetDefaultLockedCatalog() != DefaultLockedCatalog() {
t.Fatal("GetDefaultLockedCatalog should alias DefaultLockedCatalog")
}
if !HasReservedCatalog() || !GetHasReservedCatalog() {
t.Fatal("HasReservedCatalog aliases should report the package reserved catalog")
}
if !HasLockedCatalog() || !GetHasLockedCatalog() {
t.Fatal("HasLockedCatalog aliases should report the package locked catalog")
}
}
func TestPackageDefaultCatalogsIgnoreOverrides(t *testing.T) {
@ -493,6 +501,14 @@ func TestPackageCatalogFallbacksWhenNil(t *testing.T) {
t.Fatal("LockedCatalog should fall back to the canonical catalog when nil")
}
if !HasReservedCatalog() || !GetHasReservedCatalog() {
t.Fatal("HasReservedCatalog aliases should keep working when Reserved is nil")
}
if !HasLockedCatalog() || !GetHasLockedCatalog() {
t.Fatal("HasLockedCatalog aliases should keep working when Locked is nil")
}
if _, ok := GetReservedName("RESERVED"); !ok {
t.Fatal("GetReservedName should keep working when Reserved is nil")
}

View file

@ -1822,6 +1822,10 @@ func TestServiceReservedCatalog(t *testing.T) {
t.Fatal("GetReservedCatalog should alias DefaultReservedCatalog")
}
if !svc.HasReservedCatalog() || !svc.GetHasReservedCatalog() {
t.Fatal("HasReservedCatalog aliases should report the service reserved catalog")
}
if got := svc.ReservedSize(); got != catalog.Size() {
t.Fatalf("ReservedSize() = %d, want %d", got, catalog.Size())
}
@ -1970,6 +1974,10 @@ func TestServiceLockedCatalog(t *testing.T) {
t.Fatal("GetLockedCatalog should alias DefaultLockedCatalog")
}
if !svc.HasLockedCatalog() || !svc.GetHasLockedCatalog() {
t.Fatal("HasLockedCatalog aliases should report the service locked catalog")
}
if got := svc.LockedSize(); got != catalog.Size() {
t.Fatalf("LockedSize() = %d, want %d", got, catalog.Size())
}