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

Return empty array when using --json flag for list commands #736

Merged
merged 4 commits into from
Apr 13, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions internal/display/display.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ func (r *Renderer) JSONResult(data interface{}) {

func (r *Renderer) Results(data []View) {
if len(data) == 0 {
r.JSONResult([]interface{}{})
return
}

Expand Down
23 changes: 15 additions & 8 deletions test/integration/organizations-test-cases.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -107,11 +107,18 @@ tests:
- "Open the following URL in a browser: https://manage.auth0.com/dashboard/"
- "/organizations/org_"

013 - add organization members:
013 - list organization members should return an empty array if no members found:
command: auth0 orgs members list $(./test/integration/scripts/get-org-id.sh)
exit-code: 0
stdout:
contains:
- "[]"

014 - add organization members:
command: auth0 api POST "organizations/$(./test/integration/scripts/get-org-id.sh)/members" --data "{\"members\":[\"$(./test/integration/scripts/get-user-id.sh)\"]}"
exit-code: 0

014 - list organization members:
015 - list organization members:
command: auth0 orgs members list $(./test/integration/scripts/get-org-id.sh)
exit-code: 0
stdout:
Expand All @@ -123,7 +130,7 @@ tests:
config:
retries: 3

015 - list organization members as json:
016 - list organization members as json:
command: auth0 orgs members list $(./test/integration/scripts/get-org-id.sh) --json
exit-code: 0
stdout:
Expand All @@ -133,7 +140,7 @@ tests:
config:
retries: 3

016 - list organization members with invalid number:
017 - list organization members with invalid number:
command: auth0 orgs members list $(./test/integration/scripts/get-org-id.sh) --number 1001
exit-code: 1
stderr:
Expand All @@ -142,22 +149,22 @@ tests:
config:
retries: 3

017 - list organization roles:
018 - list organization roles:
command: auth0 orgs roles list $(./test/integration/scripts/get-org-id.sh)
exit-code: 0

018 - list organization roles with invalid number:
019 - list organization roles with invalid number:
command: auth0 orgs roles list $(./test/integration/scripts/get-org-id.sh) --number 1001
exit-code: 1
stderr:
contains:
- number flag invalid, please pass a number between 1 and 1000

019 - list organization roles members:
020 - list organization roles members:
command: auth0 orgs roles members list $(./test/integration/scripts/get-org-id.sh)
exit-code: 0

020 - list organization roles members with invalid number:
021 - list organization roles members with invalid number:
command: auth0 orgs roles members list $(./test/integration/scripts/get-org-id.sh) --number 1001
exit-code: 1
stderr:
Expand Down