Skip to content
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

Empty array stdout with --json flag #747

Merged
merged 14 commits into from
Apr 20, 2023
Merged

Empty array stdout with --json flag #747

merged 14 commits into from
Apr 20, 2023

Conversation

willvedd
Copy link
Contributor

@willvedd willvedd commented Apr 19, 2023

🔧 Changes

Previously, #736 was introduced to return an empty array when no results and the --json flag was passed. This addressed several commands but still missed some commands. There are certainly opportunities to refactor the code and abstract these empty state handlers but I mostly just want to get some implementation in and add test cases.

📚 References

Initial PR: #736

🔬 Testing

Added integration test cases wherever practically possible. Had to reorganize the test files to make them deterministic and independent from each other.

📝 Checklist

  • All new/changed/fixed functionality is covered by tests (or N/A)
  • I have added documentation for all new/changed functionality (or N/A)

@willvedd willvedd requested a review from a team as a code owner April 19, 2023 18:10
@@ -1,49 +0,0 @@
config:
Copy link
Contributor Author

Choose a reason for hiding this comment

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

File was rolled-into the rules test cases file.

Copy link
Contributor

@Widcket Widcket left a comment

Choose a reason for hiding this comment

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

Nice improvement.

internal/display/roles.go Outdated Show resolved Hide resolved
@codecov-commenter
Copy link

Codecov Report

Patch coverage: 60.65% and project coverage change: -0.12 ⚠️

Comparison is base (b31b615) 71.67% compared to head (e8b00b6) 71.56%.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #747      +/-   ##
==========================================
- Coverage   71.67%   71.56%   -0.12%     
==========================================
  Files          89       89              
  Lines       11160    11207      +47     
==========================================
+ Hits         7999     8020      +21     
- Misses       2658     2682      +24     
- Partials      503      505       +2     
Impacted Files Coverage Δ
internal/display/apis.go 84.89% <0.00%> (-3.83%) ⬇️
internal/display/apps.go 75.15% <0.00%> (-1.40%) ⬇️
internal/display/display.go 84.45% <0.00%> (-2.32%) ⬇️
internal/display/logs.go 52.84% <0.00%> (-1.78%) ⬇️
internal/display/users.go 77.77% <0.00%> (-7.73%) ⬇️
internal/display/actions.go 80.64% <100.00%> (+0.64%) ⬆️
internal/display/custom_domain.go 91.42% <100.00%> (+0.38%) ⬆️
internal/display/log_streams.go 100.00% <100.00%> (ø)
internal/display/organizations.go 100.00% <100.00%> (ø)
internal/display/role_permissions.go 95.55% <100.00%> (+0.31%) ⬆️
... and 3 more

... and 1 file with indirect coverage changes

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report in Codecov by Sentry.
📢 Do you have feedback about the report comment? Let us know in this issue.

internal/display/log_streams.go Outdated Show resolved Hide resolved
@@ -149,12 +149,15 @@ func (r *Renderer) LogList(logs []*management.Log, silent, hasFilter bool) {

if len(logs) == 0 {
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggestion:

if len(logs) == 0 {
	if !hasFilter {
		r.EmptyState(resource, "To generate logs, run a test command like 'auth0 test login' or 'auth0 test token'")
		return
	}
	
	r.EmptyState("logs matching filter criteria", "")
	return
}

Like this it will print "No logs matching filter criteria available." and we have less complex code.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

IMO that reads very poorly. I'm glad we were able to reduce a couple one-off instances, but I think this one still makes sense.

Copy link
Contributor

Choose a reason for hiding this comment

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

Both sentences are grammatically correct and convey the same meaning 🤷🏻‍♂️ Not a blocker tho.

internal/display/roles.go Outdated Show resolved Hide resolved
willvedd and others added 4 commits April 20, 2023 11:40
Co-authored-by: Sergiu Ghitea <28300158+sergiught@users.noreply.github.com>
Co-authored-by: Sergiu Ghitea <28300158+sergiught@users.noreply.github.com>
@willvedd willvedd merged commit f6f7172 into main Apr 20, 2023
@willvedd willvedd deleted the empty-array-json-flag branch April 20, 2023 17:17
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.

4 participants