test: Add unit tests for SensorDispatchBridge, SignalEmitter, and Error modules#10
test: Add unit tests for SensorDispatchBridge, SignalEmitter, and Error modules#10dl-alexandre wants to merge 2 commits intoagentjido:mainfrom
Conversation
…or modules Add comprehensive test coverage for three modules that previously had no tests: - SensorDispatchBridge: Tests for forward/2, forward_many/2, and forward_or_ignore/2 including success cases, error handling for dead runtimes, invalid signals, and batch forwarding with error tracking. - SignalEmitter: Tests for dispatch configuration validation, signal emission with various formats, notification handling, and default signal type/source generation from resource names. - Error: Tests for all Ash error type conversions (Invalid, Forbidden, Framework, Unknown), underlying error extraction, field error mapping, and changeset error extraction. These tests improve overall test coverage and provide safety for future refactoring.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: eca517d417
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
|
||
| result = Error.extract_underlying_errors(ash_error) | ||
|
|
||
| assert length(result) == 1 |
There was a problem hiding this comment.
Align expected underlying error extraction with implementation
This assertion expects extract_underlying_errors/1 to return one item when %Ash.Error.Unknown{error: inner_error, errors: []} is passed, but AshJido.Error.extract_underlying_errors/1 checks :errors first and returns that list when present (even if empty). As written, this test will consistently fail against the current implementation unless the input omits :errors or the function logic is changed.
Useful? React with 👍 / 👎.
test/ash_jido/error_test.exs
Outdated
|
|
||
| result = Error.extract_field_errors(ash_error) | ||
|
|
||
| assert result.name == ["is too short", "is required"] |
There was a problem hiding this comment.
Correct expected ordering of grouped field error messages
The expected order here is reversed relative to AshJido.Error.extract_field_errors/1: that function preserves insertion order from the input list via Enum.group_by/3, so with Required followed by InvalidAttribute the value for :name is [is required, is too short]. This assertion will fail deterministically with the test data in this commit.
Useful? React with 👍 / 👎.
|
Superseded by #16, which carried this coverage work forward onto current main and aligned it with the Ash/Jido APIs in use on April 1, 2026. |
Summary
Adds comprehensive unit tests for three modules that previously had no dedicated test coverage:
Modules Tested
SensorDispatchBridge (
test/ash_jido/sensor_dispatch_bridge_test.exs)forward/2with valid signals, invalid formats, and dead runtimesforward_many/2for batch forwarding with success/error trackingforward_or_ignore/2for handling signal filteringSignalEmitter (
test/ash_jido/signal_emitter_test.exs)Error (
test/ash_jido/error_test.exs)Impact