Skip to content

Commit 565f907

Browse files
committed
review changes
1 parent 60fae5d commit 565f907

File tree

4 files changed

+24
-22
lines changed

4 files changed

+24
-22
lines changed

internal/cmd/network/create/create_test.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -481,6 +481,16 @@ func TestParseInput(t *testing.T) {
481481
expectedModel: nil,
482482
isValid: false,
483483
},
484+
{
485+
description: "routing-table id not set",
486+
flagValues: fixtureFlagValues(func(flagValues map[string]string) {
487+
delete(flagValues, routingTableIdFlag)
488+
}),
489+
isValid: true,
490+
expectedModel: fixtureInputModel(func(model *inputModel) {
491+
model.RoutingTableID = nil
492+
}),
493+
},
484494
}
485495

486496
for _, tt := range tests {

internal/cmd/routingtable/create/create.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -147,15 +147,15 @@ func buildRequest(ctx context.Context, model *inputModel, apiClient *iaas.APICli
147147
}
148148

149149
func outputResult(p *print.Printer, outputFormat string, routingTable *iaas.RoutingTable) error {
150-
if routingTable == nil {
151-
return fmt.Errorf("create routing-table response is empty")
152-
}
150+
return p.OutputResult(outputFormat, routingTable, func() error {
151+
if routingTable == nil {
152+
return fmt.Errorf("create routing-table response is empty")
153+
}
153154

154-
if routingTable.Id == nil {
155-
return fmt.Errorf("routing-table Id is empty")
156-
}
155+
if routingTable.Id == nil {
156+
return fmt.Errorf("create routing-table id is empty")
157+
}
157158

158-
return p.OutputResult(outputFormat, routingTable, func() error {
159159
var labels []string
160160
if routingTable.Labels != nil && len(*routingTable.Labels) > 0 {
161161
for key, value := range *routingTable.Labels {

internal/cmd/routingtable/route/update/update.go

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -113,14 +113,6 @@ func parseInput(p *print.Printer, cmd *cobra.Command, inputArgs []string) (*inpu
113113
}
114114

115115
func outputResult(p *print.Printer, outputFormat, routingTableId, networkAreaId string, route *iaas.Route) error {
116-
if route == nil {
117-
return fmt.Errorf("update route response is empty")
118-
}
119-
120-
if route.Id == nil || *route.Id == "" {
121-
return fmt.Errorf("update route response has empty id")
122-
}
123-
124116
return p.OutputResult(outputFormat, route, func() error {
125117
if route == nil {
126118
return fmt.Errorf("update route response is empty")

internal/cmd/routingtable/update/update.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -134,15 +134,15 @@ func parseInput(p *print.Printer, cmd *cobra.Command, inputArgs []string) (*inpu
134134
}
135135

136136
func outputResult(p *print.Printer, outputFormat, networkAreaId string, routingTable *iaas.RoutingTable) error {
137-
if routingTable == nil {
138-
return fmt.Errorf("update routing-table response is empty")
139-
}
137+
return p.OutputResult(outputFormat, routingTable, func() error {
138+
if routingTable == nil {
139+
return fmt.Errorf("update routing-table response is empty")
140+
}
140141

141-
if routingTable.Id == nil {
142-
return fmt.Errorf("update routing-table response is empty")
143-
}
142+
if routingTable.Id == nil {
143+
return fmt.Errorf("update routing-table id is empty")
144+
}
144145

145-
return p.OutputResult(outputFormat, routingTable, func() error {
146146
p.Outputf("Updated routing-table %q in network-area %q.", *routingTable.Id, networkAreaId)
147147
return nil
148148
})

0 commit comments

Comments
 (0)