Skip to content

test(guardrails): add unit tests for config validation#323

Merged
leseb merged 1 commit into
praxis-proxy:mainfrom
leseb:leseb/test-guardrails-282
Jul 9, 2026
Merged

test(guardrails): add unit tests for config validation#323
leseb merged 1 commit into
praxis-proxy:mainfrom
leseb:leseb/test-guardrails-282

Conversation

@leseb

@leseb leseb commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Add inline unit tests for the guardrails config module (filters/src/guardrails/config.rs)
  • Cover ProviderType serde, PhaseConfig defaults/custom/deny_unknown_fields, AiGuardrailsConfig serde
  • Strengthen existing body_mode_is_stream_buffer test to assert exact max_bytes value
  • Use #[cfg_attr(not(test), expect(dead_code, ...))] for fields only read in tests

Closes #282

Test plan

  • cargo test -p praxis-ai-filters -- guardrails — all tests pass
  • make lint — clippy + nightly rustfmt clean

)

Add config-level unit tests for ProviderType serde, PhaseConfig
defaults/overrides/deny_unknown_fields, and AiGuardrailsConfig
serde validation. Strengthen the body_mode test to assert the exact
1 MiB StreamBuffer limit. Convert dead_code expects on PhaseConfig
fields to cfg_attr(not(test)) so tests can read the fields.

Signed-off-by: Sébastien Han <seb@redhat.com>
@leseb leseb requested review from a team and alexsnaps July 9, 2026 14:30
@leseb leseb added this pull request to the merge queue Jul 9, 2026

@praxis-bot praxis-bot left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Review: test(guardrails): add unit tests for config validation

Well-scoped PR. The cfg_attr(not(test), expect(dead_code, ...)) pattern is correct, the assert_eq! strengthening in body_mode_is_stream_buffer is a nice improvement, and the new config tests cover the important serde paths (defaults, custom values, deny_unknown_fields, missing required fields).

Severity File Finding
Medium tests.rs:358-359 Missing assertion messages in guardrails_config_with_phase_overrides
Medium mod.rs:15-17 Unused lint suppressions added to blanket allow

Note on mod.rs: The three new suppressions (expect_used, needless_raw_strings, needless_raw_string_hashes) are not triggered by any code in the test module — no test uses .expect(), and every raw string legitimately contains embedded " characters. Consider adding suppressions only when code that needs them arrives, to keep the allow list honest.

Comment thread filters/src/guardrails/tests.rs
Merged via the queue into praxis-proxy:main with commit 47a0ffb Jul 9, 2026
17 checks passed
@leseb leseb deleted the leseb/test-guardrails-282 branch July 9, 2026 18:59
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.

test: add unit tests for guardrails filter

3 participants