test(uuid): add unit test fixtures for UUID v4 format and casing verification - #9012
test(uuid): add unit test fixtures for UUID v4 format and casing verification#9012gcoinstash-cmd wants to merge 1 commit into
Conversation
Reviewer's GuideIntroduces a dependency-free Rust test module that validates canonical UUID v4 string formatting, nil UUID serialization, and case-insensitive parsing. File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
|
|
There was a problem hiding this comment.
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>| @@ -0,0 +1,28 @@ | |||
| #[cfg(test)] | |||
There was a problem hiding this comment.
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.
| 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); |
There was a problem hiding this comment.
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.
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: