-
-
Notifications
You must be signed in to change notification settings - Fork 117
Better Handle Empty Tables #1228
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #1228 +/- ##
==========================================
+ Coverage 33.56% 33.60% +0.03%
==========================================
Files 226 226
Lines 24219 24205 -14
==========================================
+ Hits 8130 8133 +3
+ Misses 14875 14858 -17
Partials 1214 1214
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
pkg/list/utils/utils.go
Outdated
lines := strings.Split(output, "\n") | ||
|
||
// Remove empty lines | ||
var nonEmptyLines []string | ||
for _, line := range lines { | ||
if strings.TrimSpace(line) != "" { | ||
nonEmptyLines = append(nonEmptyLines, line) | ||
} | ||
} | ||
|
||
// A table is empty if it has 2 or fewer non-empty lines (header and separator) | ||
return len(nonEmptyLines) <= 2 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems odd to me we have this function to begin with. A table is empty if it has no data, and data is fed to the table presumably. Why are we addressing the symptom "A table is empty if it has 2 or fewer non-empty lines (header and separator)" rather than the cause?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree actually I found a better approach to remove that and directly return the correct result in the FilterAndListValues
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
so we already have listerrors.NoValuesFoundError and also tests for that we can just delete it
Important Cloud Posse Engineering Team Review RequiredThis pull request modifies files that require Cloud Posse's review. Please be patient, and a core maintainer will review your changes. To expedite this process, reach out to us on Slack in the |
📝 WalkthroughWalkthroughThe changes remove the Changes
Suggested labels
✨ Finishing Touches
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. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
Documentation and Community
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
🧹 Nitpick comments (1)
pkg/list/utils/utils_test.go (1)
139-180
: Good test case coverage for component existence.The test cases effectively cover existing components, path-based components, non-existent components, ignored section components, and empty component names.
Consider adding one more test case for a deeply nested path (e.g., "path/to/deeper/comp-a") to ensure the extraction of the base component name works correctly with arbitrary path depths.
📜 Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (4)
cmd/list_metadata.go
(0 hunks)cmd/list_settings.go
(0 hunks)pkg/list/utils/utils.go
(0 hunks)pkg/list/utils/utils_test.go
(1 hunks)
💤 Files with no reviewable changes (3)
- pkg/list/utils/utils.go
- cmd/list_settings.go
- cmd/list_metadata.go
🧰 Additional context used
🧬 Code Graph Analysis (1)
pkg/list/utils/utils_test.go (2)
pkg/list/errors/types.go (1)
NoValuesFoundError
(9-12)pkg/list/utils/utils.go (1)
IsNoValuesFoundError
(12-15)
⏰ Context from checks skipped due to timeout of 90000ms (2)
- GitHub Check: Build (windows-latest, windows)
- GitHub Check: Summary
🔇 Additional comments (5)
pkg/list/utils/utils_test.go (5)
13-24
: Well-structured mock for error type testing.Good approach for creating a mock error type. The implementation correctly implements the Error interface, which is essential for testing type assertions against the actual NoValuesFoundError.
26-61
: Comprehensive test coverage for IsNoValuesFoundError.The table-driven test approach is solid, covering all critical scenarios including custom mock errors, standard errors, nil errors, and actual NoValuesFoundError instances. This ensures the function correctly identifies only the specific error type it should match.
63-138
: Well-implemented test logic for component existence checks.The helper function effectively mimics the core processing loop of CheckComponentExists. The detailed comments on each line explaining which part of the original function is being covered show thoughtful test design.
68-105
: Thorough test data covering various scenarios.Your simulated stack map covers an excellent range of scenarios: valid structures, malformed data at different levels, and edge cases. This comprehensive approach ensures the component existence logic is thoroughly tested.
1-11
: Proper package and import structure.The test package is correctly named with the _test suffix and imports the necessary dependencies. Using the testify/assert package makes the tests more readable.
what
Identified issues when considering that the table is "empty"
why
Added full tests for utils and empty table cases
Making sure we validate the places where we are using these utils pkg and block future regressions
references
Summary by CodeRabbit
Bug Fixes
Tests