Skip to content

test(ingress): meta-test that every column-writing Buffer method has an _opt twin#139

Open
aaaronme wants to merge 2 commits intoquestdb:mainfrom
aaaronme:test/column-method-opt-coverage
Open

test(ingress): meta-test that every column-writing Buffer method has an _opt twin#139
aaaronme wants to merge 2 commits intoquestdb:mainfrom
aaaronme:test/column-method-opt-coverage

Conversation

@aaaronme
Copy link
Copy Markdown
Contributor

@aaaronme aaaronme commented Apr 24, 2026

Summary

Follow-up to #134. Adds a meta-test in tests/buffer_opt.rs that scans buffer.rs and asserts every column-writing method has a matching _opt sibling.

Column writers are detected by the N: TryInto<ColumnName<'a>> generic bound rather than by a column_* name prefix — so symbol and any future unprefixed method (e.g. a hypothetical uuid) are also covered. If someone lands column_uuid or uuid without a _opt companion, the test fails with the missing names listed.

Two short regexes do the work; [^{]* matches across newlines so it spans multi-line where clauses without dotall. Adds regex to dev-dependencies (already pulled in transitively by other crates, so no new top-level dep at build time).

Test plan

  • cargo test --lib buffer_opt — all 6 tests pass, including the new test_every_column_writing_method_has_opt_variant
  • Locally remove one _opt method from buffer.rs and confirm the test fails with that method name in the assertion message

Summary by CodeRabbit

  • Tests

    • Added internal validation test to ensure API consistency across methods.
  • Chores

    • Updated development dependencies for testing infrastructure.

…` twin

   Adds a meta-test that scans `buffer.rs` and asserts every column-writing
   method (identified by the `N: TryInto<ColumnName<'a>>` bound rather than
   by name prefix) has a matching `_opt` sibling. Catches the case where a
   new method like `uuid` or `column_uuid` lands without its `_opt` twin.

   - Adds `regex` to dev-dependencies
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 24, 2026

Warning

Rate limit exceeded

@aaaronme has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 23 minutes and 27 seconds before requesting another review.

Your organization is not enrolled in usage-based pricing. Contact your admin to enable usage-based pricing to continue reviews beyond the rate limit, or try again in 23 minutes and 27 seconds.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 7a7755f8-381c-4ac5-8921-0f51d704a344

📥 Commits

Reviewing files that changed from the base of the PR and between a0cd3a1 and 0e9f321.

📒 Files selected for processing (1)
  • questdb-rs/src/tests/buffer_opt.rs
📝 Walkthrough

Walkthrough

This PR adds a compile-time test that uses regex to verify every public column-writing method in the Buffer implementation has a corresponding _opt variant. The regex crate is added to dev-dependencies to support the test.

Changes

Cohort / File(s) Summary
Build Configuration
Cargo.toml
Added regex crate to dev-dependencies for test support.
Test Addition
src/tests/buffer_opt.rs
New test that parses buffer.rs at compile time using regex to enumerate public column-writing methods and verifies each has a corresponding _opt sibling method; fails with a list of missing variants if any are found.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Possibly related PRs

Suggested reviewers

  • jerrinot

Poem

🐰 A test hops into the meadow bright,
Checking methods with regex sight,
Each column writer paired with _opt care,
Validation guards ensure all is fair! ✨

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately and concisely describes the main change: introducing a meta-test that verifies every column-writing Buffer method has a corresponding _opt variant.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
questdb-rs/src/tests/buffer_opt.rs (1)

157-158: Optional: harden the regexes against pub fn strings appearing in doc comments / examples.

pub fn patterns occurring inside /// doc comments or //! module docs in buffer.rs (e.g., usage examples) will be picked up by both regexes. For the writer regex this only matters if a doc example happens to also contain TryInto<ColumnName between the name and the next {; for the pub_fn set it's mostly benign (extra entries can only mask a missing _opt, never cause a spurious failure). It's not exploitable today, but a future doc example like /// pub fn uuid<N>(... where N: TryInto<ColumnName<'a>> ... could quietly hide a real gap.

Two cheap mitigations if you want to make this future-proof:

  • Anchor on indentation typical for impl items (e.g., (?m)^ pub fn (\w+)), which excludes ///-prefixed lines.
  • Or strip line comments before scanning: let src = src.lines().filter(|l| !l.trim_start().starts_with("//")).collect::<Vec<_>>().join("\n");.

Up to you — the current implementation is fine for the code as it stands today.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@questdb-rs/src/tests/buffer_opt.rs` around lines 157 - 158, The current
regexes pub_fn and writer can match `pub fn` inside doc comments; to harden,
either anchor them to impl-style indentation (e.g., update the patterns used for
pub_fn and writer to use multiline anchors like (?m)^\s{4}pub fn (\w+) and
(?m)^\s{4}pub fn (\w+)[^{]*TryInto<ColumnName) so doc-comment lines are
excluded, or preprocess the source (the src string read from buffer.rs) by
stripping line comments/doc comments (filter out lines where
l.trim_start().starts_with("///") or l.trim_start().starts_with("//") or
starts_with("//!")) before running the existing regexes; apply the chosen change
to the code that constructs pub_fn and writer so matches only come from real
impl/function definitions.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@questdb-rs/src/tests/buffer_opt.rs`:
- Around line 157-158: The current regexes pub_fn and writer can match `pub fn`
inside doc comments; to harden, either anchor them to impl-style indentation
(e.g., update the patterns used for pub_fn and writer to use multiline anchors
like (?m)^\s{4}pub fn (\w+) and (?m)^\s{4}pub fn (\w+)[^{]*TryInto<ColumnName)
so doc-comment lines are excluded, or preprocess the source (the src string read
from buffer.rs) by stripping line comments/doc comments (filter out lines where
l.trim_start().starts_with("///") or l.trim_start().starts_with("//") or
starts_with("//!")) before running the existing regexes; apply the chosen change
to the code that constructs pub_fn and writer so matches only come from real
impl/function definitions.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: e86b5c33-7ad2-4a94-a44c-60ac36e21945

📥 Commits

Reviewing files that changed from the base of the PR and between d63929b and a0cd3a1.

📒 Files selected for processing (2)
  • questdb-rs/Cargo.toml
  • questdb-rs/src/tests/buffer_opt.rs

Adds `(?m)^\s*` to both regexes so matches must start at indentation, not mid-line. A future `pub fn ...` inside a `///` doc example can no longer  be picked up — which would otherwise silently mask a missing `_opt` win if the same example also referenced `TryInto<ColumnName`.
  Today no doc example triggers this, so behavior is unchanged. The fix is preventative.
@aaaronme
Copy link
Copy Markdown
Contributor Author

@jerrinot wdyt?
also considered CodeRabbits comment about excluding doc comments / examples

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.

1 participant