chore(test): Add test for placeholder presence#281
Conversation
WalkthroughA new unit test, ChangesTest: placeholder presence
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
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. Review rate limit: 0/1 reviews remaining, refill in 60 minutes.Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@console-rs/src/lib.rs`:
- Around line 210-220: The test is iterating raw stored paths and calling
LakekeeperConsole::get which returns gzipped bytes, so UTF-8 checks always fail;
replace use of LakekeeperConsole::iter() with the test-only
LakekeeperConsole::embedded_iter() (which strips .gz suffixes) and call
LakekeeperConsole::embedded(name) instead of LakekeeperConsole::get(file_path)
so you receive decompressed content before running
std::str::from_utf8(...).contains(placeholder); update references in the loop to
use embedded_iter() and embedded() (or their returned bytes) so placeholders are
checked against decompressed text.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 41298aee-0974-4621-bb83-a53f2cb81c0f
📒 Files selected for processing (1)
console-rs/src/lib.rs
| let files: Vec<_> = LakekeeperConsole::iter().collect(); | ||
| let mut found = Vec::new(); | ||
| let mut missing = Vec::new(); | ||
|
|
||
| for placeholder in &placeholders { | ||
| let is_found = files.iter().any(|file_path| { | ||
| LakekeeperConsole::get(file_path).is_some_and(|file| { | ||
| std::str::from_utf8(&file.data) | ||
| .is_ok_and(|content| content.contains(placeholder)) | ||
| }) | ||
| }); |
There was a problem hiding this comment.
Gzipped assets are not decompressed — placeholders will be falsely reported as missing
LakekeeperConsole::iter() yields the raw stored paths (including .js.gz, .html.gz, etc. produced by build.rs). LakekeeperConsole::get(file_path) then returns the raw compressed bytes, and std::str::from_utf8 fails on gzip binary content, so is_ok_and(…) is always false for those entries. In a build where large JS assets are stored only as .gz, all 11 placeholders would be reported as missing — a false failure that directly defeats the test's purpose.
The project already exposes the two helpers needed to fix this: the #[cfg(test)]-gated embedded_iter() (which strips .gz suffixes, lines 81–89) and the public embedded() (which decompresses transparently, lines 64–75). test_get_all_files uses exactly these two; the new test should too.
🐛 Proposed fix
- let files: Vec<_> = LakekeeperConsole::iter().collect();
+ let files: Vec<_> = embedded_iter().collect();
let mut found = Vec::new();
let mut missing = Vec::new();
for placeholder in &placeholders {
let is_found = files.iter().any(|file_path| {
- LakekeeperConsole::get(file_path).is_some_and(|file| {
+ embedded(file_path.as_ref()).is_some_and(|file| {
std::str::from_utf8(&file.data)
.is_ok_and(|content| content.contains(placeholder))
})
});📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| let files: Vec<_> = LakekeeperConsole::iter().collect(); | |
| let mut found = Vec::new(); | |
| let mut missing = Vec::new(); | |
| for placeholder in &placeholders { | |
| let is_found = files.iter().any(|file_path| { | |
| LakekeeperConsole::get(file_path).is_some_and(|file| { | |
| std::str::from_utf8(&file.data) | |
| .is_ok_and(|content| content.contains(placeholder)) | |
| }) | |
| }); | |
| let files: Vec<_> = embedded_iter().collect(); | |
| let mut found = Vec::new(); | |
| let mut missing = Vec::new(); | |
| for placeholder in &placeholders { | |
| let is_found = files.iter().any(|file_path| { | |
| embedded(file_path.as_ref()).is_some_and(|file| { | |
| std::str::from_utf8(&file.data) | |
| .is_ok_and(|content| content.contains(placeholder)) | |
| }) | |
| }); |
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@console-rs/src/lib.rs` around lines 210 - 220, The test is iterating raw
stored paths and calling LakekeeperConsole::get which returns gzipped bytes, so
UTF-8 checks always fail; replace use of LakekeeperConsole::iter() with the
test-only LakekeeperConsole::embedded_iter() (which strips .gz suffixes) and
call LakekeeperConsole::embedded(name) instead of
LakekeeperConsole::get(file_path) so you receive decompressed content before
running std::str::from_utf8(...).contains(placeholder); update references in the
loop to use embedded_iter() and embedded() (or their returned bytes) so
placeholders are checked against decompressed text.
Summary by CodeRabbit