Skip to content

test(di): add service_container integration tests and fix public headers#384

Merged
kcenon merged 1 commit into
mainfrom
refactor/issue-369-migrate-database-system-to-service-container
Feb 23, 2026
Merged

test(di): add service_container integration tests and fix public headers#384
kcenon merged 1 commit into
mainfrom
refactor/issue-369-migrate-database-system-to-service-container

Conversation

@kcenon

@kcenon kcenon commented Feb 23, 2026

Copy link
Copy Markdown
Owner

Closes kcenon/common_system#369

Summary

  • Add 25 unit tests for service_registration.h validating integration with common_system::di::service_container
  • Fix broken relative include paths in service_registration.h and common_system_database_adapter.h (../../database/database/)
  • Fix renamed enum value: database_types::postgresqldatabase_types::postgres
  • Add DI test target to tests/CMakeLists.txt gated on BUILD_WITH_COMMON_SYSTEM

Context

Part of the DI container consolidation effort (kcenon/common_system#363, Phase 5).

database_system has no legacy internal DI container — service_registration.h already correctly uses service_container. However, the public headers under include/kcenon/database/ had never been compiled and contained broken include paths and a renamed enum reference. This PR fixes those issues and adds comprehensive test coverage.

The database_coordinator intentionally manages adapter lifecycle with phase-aware initialization ordering (Logger → Monitor → Thread) and is not a DI container. No refactoring of the coordinator is needed.

Test Coverage (25 tests)

Category Tests
Registration Default config, custom config, transient, duplicate error, register_all, instance, null instance error
Resolution Singleton same instance, transient different instances, valid IDatabase, resolve_or_null
Unregister Success, not-registered error
Utilities get_underlying_manager (factory), get_underlying_manager (instance)
Container Clear, freeze prevents registration, freeze allows resolution
Thread safety Concurrent singleton resolve, concurrent transient resolve
Descriptors registered_services returns descriptors
Scoping Scoped container inherits registration

Test Plan

  • All 25 new DI tests pass
  • All 660 existing tests pass (6 pre-existing failures in CredentialSecurityTest unrelated to this change)
  • Full build succeeds with USE_CONTAINER_SYSTEM=OFF

Add 25 unit tests validating database_system's service_registration.h
API works correctly with common_system's service_container. Tests cover
registration (factory/instance/transient/singleton), resolution,
unregister, freeze, scoped containers, thread safety, and the
get_underlying_database_manager utility.

Fix pre-existing bugs in public headers that were never compiled:
- Fix broken relative include paths in service_registration.h and
  common_system_database_adapter.h (../../database/ -> database/)
- Fix renamed enum: database_types::postgresql -> database_types::postgres

Part of kcenon/common_system#369
@kcenon kcenon merged commit b90b0f3 into main Feb 23, 2026
23 checks passed
@kcenon kcenon deleted the refactor/issue-369-migrate-database-system-to-service-container branch February 23, 2026 12:16
kcenon added a commit that referenced this pull request Apr 13, 2026
…ers (#384)

Add 25 unit tests validating database_system's service_registration.h
API works correctly with common_system's service_container. Tests cover
registration (factory/instance/transient/singleton), resolution,
unregister, freeze, scoped containers, thread safety, and the
get_underlying_database_manager utility.

Fix pre-existing bugs in public headers that were never compiled:
- Fix broken relative include paths in service_registration.h and
  common_system_database_adapter.h (../../database/ -> database/)
- Fix renamed enum: database_types::postgresql -> database_types::postgres

Part of kcenon/common_system#369
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

refactor(di): Phase 5 — migrate database_system to service_container

1 participant