Skip to content

Commit

Permalink
chore: change listing and unit test
Browse files Browse the repository at this point in the history
  • Loading branch information
PatrickMenoti committed Mar 3, 2023
1 parent 7ed0a6a commit b1e5017
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
4 changes: 2 additions & 2 deletions pkg/cmd/domains/list/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ func PrintTable(cmd *cobra.Command, f *cmdutil.Factory, opts *contracts.ListOpti
tbl := table.New("ID", "NAME")
table.DefaultWriter = f.IOStreams.Out
if cmd.Flags().Changed("details") {
tbl = table.New("ID", "NAME", "EDGE DOMAIN", "ACTIVE", "DIGITAL CERTIFICATE ID", "EDGE APPLICATION ID", "CNAME ACCESS ONLY", "CNAMES")
tbl = table.New("ID", "NAME", "EDGE DOMAIN", "DIGITAL CERTIFICATE ID", "EDGE APPLICATION ID", "CNAME ACCESS ONLY", "CNAMES", "ACTIVE")
}

headerFmt := color.New(color.FgBlue, color.Underline).SprintfFunc()
Expand All @@ -61,7 +61,7 @@ func PrintTable(cmd *cobra.Command, f *cmdutil.Factory, opts *contracts.ListOpti

if cmd.Flags().Changed("details") {
for _, v := range domains.Results {
tbl.AddRow(v.Id, v.Name, *v.DomainName, *v.IsActive, v.DigitalCertificateId.Get(), *v.EdgeApplicationId, *v.CnameAccessOnly, *v.Cnames)
tbl.AddRow(v.Id, v.Name, *v.DomainName, v.DigitalCertificateId.Get(), *v.EdgeApplicationId, *v.CnameAccessOnly, *v.Cnames, *v.IsActive)
}
} else {
for _, v := range domains.Results {
Expand Down
7 changes: 7 additions & 0 deletions utils/helpers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,4 +85,11 @@ func TestCobraCmd(t *testing.T) {
require.Contains(t, azJsonData.Function.File, "myfile.js")
require.EqualValues(t, azJsonData.Function.Id, 476)
})

t.Run("returns invalid order_by", func(t *testing.T) {
body := `{"invalid_order_field":"'edge_domain' is not a valid option for 'order_by'","available_order_fields":["id","name","cnames","cname_access_only","digital_certificate_id","edge_application_id","is_active"]}`
err := checkOrderField(body)

require.Equal(t, `'edge_domain' is not a valid option for 'order_by'`, err.Error())
})
}

0 comments on commit b1e5017

Please sign in to comment.