Skip to content

test(uuid): add unit test fixtures for UUID v4 format and casing verification - #9012

Open
gcoinstash-cmd wants to merge 1 commit into
AppFlowy-IO:mainfrom
gcoinstash-cmd:test/rust-uuid-validation-fixtures
Open

test(uuid): add unit test fixtures for UUID v4 format and casing verification#9012
gcoinstash-cmd wants to merge 1 commit into
AppFlowy-IO:mainfrom
gcoinstash-cmd:test/rust-uuid-validation-fixtures

Conversation

@gcoinstash-cmd

@gcoinstash-cmd gcoinstash-cmd commented Sep 12, 2026

Copy link
Copy Markdown

Summary

Adds self-contained unit tests for UUID v4 string generation, hyphen delimiter counts, nil identifier invariants, and case-insensitive string parsing.

Verification

Isolated Rust test suite with 0 dependencies added.

Summary by Sourcery

Tests:

  • Add UUID validation tests covering v4 string formatting, nil UUID representation, and case-insensitive parsing.

@sourcery-ai

sourcery-ai Bot commented Sep 12, 2026

Copy link
Copy Markdown
Contributor

Reviewer's Guide

Introduces a dependency-free Rust test module that validates canonical UUID v4 string formatting, nil UUID serialization, and case-insensitive parsing.

File-Level Changes

Change Details Files
Adds isolated unit-test coverage for UUID v4 formatting and parsing behavior.
  • Verifies generated UUID strings have the canonical 36-character length and four hyphen delimiters.
  • Verifies the nil UUID serializes to its expected all-zero representation.
  • Verifies parsing accepts both lowercase and uppercase UUID strings and produces equivalent values.
frontend/core_services/tests/uuid_v4_validation_test.rs

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@CLAassistant

Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Hey - I've found 2 issues

Prompt for AI Agents
Please address the comments from this code review:

## Individual Comments

### Comment 1
<location path="frontend/core_services/tests/uuid_v4_validation_test.rs" line_range="1" />
<code_context>
+#[cfg(test)]
+mod tests {
+    use uuid::Uuid;
</code_context>
<issue_to_address>
**issue (testing):** This test file is not attached to any Cargo package: `frontend/core_services` has no `Cargo.toml` and is not a member of the `frontend/rust-lib` workspace, so Cargo does not compile or run these tests.

**Triggers:** When the Rust workspace test suite is run through Cargo.

**Suggested fix:** Place the test under an existing package's `tests` directory or add `frontend/core_services` as a valid Cargo package and workspace member.
</issue_to_address>

### Comment 2
<location path="frontend/core_services/tests/uuid_v4_validation_test.rs" line_range="7-10" />
<code_context>
+
+    #[test]
+    fn test_appflowy_uuid_v4_generation_format() {
+        let id = Uuid::new_v4();
+        let id_str = id.to_string();
+        assert_eq!(id_str.len(), 36);
+        assert_eq!(id_str.chars().filter(|&c| c == '-').count(), 4);
+    }
+
</code_context>
<issue_to_address>
**nitpick (testing):** The test only checks canonical UUID length and delimiter count; it passes for UUID v1, v3, v5, or any other 36-character hyphenated UUID and therefore never verifies the v4 version or required variant bits.

**Triggers:** When UUID version/variant formatting regresses while the string retains the same length and delimiter layout.

**Suggested fix:** Assert the UUID version is random/v4 and the variant is RFC 4122, in addition to checking the string shape.
</issue_to_address>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨

@@ -0,0 +1,28 @@
#[cfg(test)]

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

issue (testing): This test file is not attached to any Cargo package: frontend/core_services has no Cargo.toml and is not a member of the frontend/rust-lib workspace, so Cargo does not compile or run these tests.

Triggers: When the Rust workspace test suite is run through Cargo.

Suggested fix: Place the test under an existing package's tests directory or add frontend/core_services as a valid Cargo package and workspace member.

Comment on lines +7 to +10
let id = Uuid::new_v4();
let id_str = id.to_string();
assert_eq!(id_str.len(), 36);
assert_eq!(id_str.chars().filter(|&c| c == '-').count(), 4);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

nitpick (testing): The test only checks canonical UUID length and delimiter count; it passes for UUID v1, v3, v5, or any other 36-character hyphenated UUID and therefore never verifies the v4 version or required variant bits.

Triggers: When UUID version/variant formatting regresses while the string retains the same length and delimiter layout.

Suggested fix: Assert the UUID version is random/v4 and the variant is RFC 4122, in addition to checking the string shape.

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