Skip to content

test: complete unit test coverage for DI container and EventBus (GIT-55)#26

Merged
TonyCasey merged 1 commit intomainfrom
tony/git-55-unit-tests-for-di-container-and-eventbus
Feb 12, 2026
Merged

test: complete unit test coverage for DI container and EventBus (GIT-55)#26
TonyCasey merged 1 commit intomainfrom
tony/git-55-unit-tests-for-di-container-and-eventbus

Conversation

@TonyCasey
Copy link
Copy Markdown
Owner

@TonyCasey TonyCasey commented Feb 12, 2026

Summary

  • Fills remaining test coverage gaps for EventBus and DI container identified in GIT-55
  • EventBus: adds logger warning verification on handler failure + explicit no-logger safety test
  • Container: adds memoryContextLoader/contextFormatter resolution checks + hook service interface method assertions

Closes GIT-55

Test plan

  • node --import tsx --test tests/unit/infrastructure/events/EventBus.test.ts — 12 pass
  • node --import tsx --test tests/unit/infrastructure/di/container.test.ts — 14 pass
  • npm run pre-commit — type-check + lint clean

🤖 Generated with Claude Code

Summary by CodeRabbit

  • New Features

    • Added memoryContextLoader and contextFormatter services to the dependency injection container for enhanced context management and data formatting.
  • Tests

    • Expanded test coverage for event bus error handling, verifying proper logging behavior when handlers fail and graceful operation without logger configuration.

Add missing test cases:
- EventBus: logger.warn called on handler failure with event/handler context
- EventBus: explicit no-logger safety test (no crash on failure)
- Container: memoryContextLoader and contextFormatter resolution checks
- Container: hook services expose expected interface methods

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings February 12, 2026 21:17
@chatgpt-codex-connector
Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, you can upgrade your account or add credits to your account and enable them for code reviews in your settings.

@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Feb 12, 2026

Caution

Review failed

The pull request is closed.

📝 Walkthrough

Walkthrough

This PR adds unit tests for two new hook services (memoryContextLoader and contextFormatter) registered in the DI container cradle, and adds test coverage for EventBus error logging behavior with and without a logger present.

Changes

Cohort / File(s) Summary
DI Container Hook Services
tests/unit/infrastructure/di/container.test.ts
Added runtime assertions validating presence of memoryContextLoader (with load method) and contextFormatter (with format method) in the cradle, plus a cohesive "hook services" test block verifying interfaces on these services and sessionCaptureService.
EventBus Logging
tests/unit/infrastructure/events/EventBus.test.ts
Added tests verifying EventBus logs warnings when handlers fail (with event, handler, and error details), and gracefully handles missing logger without crashing.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch tony/git-55-unit-tests-for-di-container-and-eventbus

Comment @coderabbitai help to get the list of available commands and usage tips.

@TonyCasey TonyCasey merged commit 8054792 into main Feb 12, 2026
6 of 7 checks passed
@TonyCasey TonyCasey deleted the tony/git-55-unit-tests-for-di-container-and-eventbus branch February 12, 2026 21:18
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This pull request adds unit tests to complete coverage for the EventBus and DI container modules as part of addressing GIT-55. The changes focus on filling specific coverage gaps that were previously identified.

Changes:

  • Added EventBus logger warning verification test and no-logger safety test
  • Added DI container tests for hook service resolution and interface method validation

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
tests/unit/infrastructure/events/EventBus.test.ts Adds two new tests: one to verify logger warning behavior when handlers fail, and another to ensure EventBus doesn't crash when no logger is provided
tests/unit/infrastructure/di/container.test.ts Adds assertions for memoryContextLoader and contextFormatter resolution in the existing service resolution test, and adds a new test suite for hook services that validates interface methods

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +170 to +172
assert.equal(typeof memoryContextLoader.load, 'function');
assert.equal(typeof contextFormatter.format, 'function');
assert.equal(typeof sessionCaptureService.capture, 'function');
Copy link

Copilot AI Feb 12, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The assertion pattern here is inconsistent with the existing pattern in this file. On lines 141-143, the eventBus tests use assert.ok(typeof x === 'function') to check for function types. For consistency, these assertions should follow the same pattern.

Suggested change
assert.equal(typeof memoryContextLoader.load, 'function');
assert.equal(typeof contextFormatter.format, 'function');
assert.equal(typeof sessionCaptureService.capture, 'function');
assert.ok(typeof memoryContextLoader.load === 'function');
assert.ok(typeof contextFormatter.format === 'function');
assert.ok(typeof sessionCaptureService.capture === 'function');

Copilot uses AI. Check for mistakes.
@TonyCasey TonyCasey restored the tony/git-55-unit-tests-for-di-container-and-eventbus branch February 14, 2026 15:10
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.

2 participants