@@ -9,10 +9,10 @@ import (
99 "github.com/google/go-cmp/cmp"
1010 "github.com/google/go-cmp/cmp/cmpopts"
1111 "github.com/google/uuid"
12- "github.com/stackitcloud/stackit-cli/internal/cmd/params"
1312 "github.com/stackitcloud/stackit-cli/internal/pkg/globalflags"
14- pprint "github.com/stackitcloud/stackit-cli/internal/pkg/print"
13+ "github.com/stackitcloud/stackit-cli/internal/pkg/print"
1514 "github.com/stackitcloud/stackit-cli/internal/pkg/testutils"
15+ "github.com/stackitcloud/stackit-cli/internal/pkg/types"
1616 "github.com/stackitcloud/stackit-cli/internal/pkg/utils"
1717 "github.com/stackitcloud/stackit-sdk-go/services/iaas"
1818)
@@ -29,8 +29,12 @@ var testNetworkAreaId = uuid.NewString()
2929
3030const testRoutingTableName = "test"
3131const testRoutingTableDescription = "test"
32- const systemRoutesDisabled = true
33- const dynamicRoutesDisabled = true
32+
33+ // Defaults: “non-system” / “non-dynamic” routes disabled = false
34+ // => system + dynamic routes enabled by default.
35+ const systemRoutesDisabled = false
36+ const dynamicRoutesDisabled = false
37+
3438const testLabelSelectorFlag = "key1=value1,key2=value2"
3539
3640var testLabels = & map [string ]string {
@@ -85,15 +89,9 @@ func fixtureRequest(mods ...func(request *iaas.ApiAddRoutingTableToAreaRequest))
8589}
8690
8791func fixturePayload (mods ... func (payload * iaas.AddRoutingTableToAreaPayload )) iaas.AddRoutingTableToAreaPayload {
88- systemRoutes := true
89- if dynamicRoutesDisabled {
90- systemRoutes = false
91- }
92-
93- dynamicRoutes := true
94- if systemRoutesDisabled {
95- dynamicRoutes = false
96- }
92+ // Actual booleans are the negation of the corresponding disabled flags.
93+ systemRoutes := ! systemRoutesDisabled
94+ dynamicRoutes := ! dynamicRoutesDisabled
9795
9896 payload := iaas.AddRoutingTableToAreaPayload {
9997 Description : utils .Ptr (testRoutingTableDescription ),
@@ -124,7 +122,7 @@ func TestParseInput(t *testing.T) {
124122 expectedModel : fixtureInputModel (),
125123 },
126124 {
127- description : "dynamic_routes disabled" ,
125+ description : "dynamic routes disabled" ,
128126 flagValues : fixtureFlagValues (func (flagValues map [string ]string ) {
129127 flagValues [nonDynamicRoutesFlag ] = "true"
130128 }),
@@ -134,7 +132,7 @@ func TestParseInput(t *testing.T) {
134132 }),
135133 },
136134 {
137- description : "system_routes disabled" ,
135+ description : "system routes disabled" ,
138136 flagValues : fixtureFlagValues (func (flagValues map [string ]string ) {
139137 flagValues [nonSystemRoutesFlag ] = "true"
140138 }),
@@ -243,9 +241,11 @@ func TestBuildRequest(t *testing.T) {
243241 model .Labels = nil
244242 }),
245243 expectedRequest : fixtureRequest (func (request * iaas.ApiAddRoutingTableToAreaRequest ) {
246- * request = (* request ).AddRoutingTableToAreaPayload (fixturePayload (func (payload * iaas.AddRoutingTableToAreaPayload ) {
247- payload .Labels = nil
248- }))
244+ * request = (* request ).AddRoutingTableToAreaPayload (
245+ fixturePayload (func (payload * iaas.AddRoutingTableToAreaPayload ) {
246+ payload .Labels = nil
247+ }),
248+ )
249249 }),
250250 },
251251 {
@@ -254,9 +254,11 @@ func TestBuildRequest(t *testing.T) {
254254 model .NonSystemRoutes = true
255255 }),
256256 expectedRequest : fixtureRequest (func (request * iaas.ApiAddRoutingTableToAreaRequest ) {
257- * request = (* request ).AddRoutingTableToAreaPayload (fixturePayload (func (payload * iaas.AddRoutingTableToAreaPayload ) {
258- payload .SystemRoutes = utils .Ptr (false )
259- }))
257+ * request = (* request ).AddRoutingTableToAreaPayload (
258+ fixturePayload (func (payload * iaas.AddRoutingTableToAreaPayload ) {
259+ payload .SystemRoutes = utils .Ptr (false )
260+ }),
261+ )
260262 }),
261263 },
262264 {
@@ -265,9 +267,11 @@ func TestBuildRequest(t *testing.T) {
265267 model .NonDynamicRoutes = true
266268 }),
267269 expectedRequest : fixtureRequest (func (request * iaas.ApiAddRoutingTableToAreaRequest ) {
268- * request = (* request ).AddRoutingTableToAreaPayload (fixturePayload (func (payload * iaas.AddRoutingTableToAreaPayload ) {
269- payload .DynamicRoutes = utils .Ptr (false )
270- }))
270+ * request = (* request ).AddRoutingTableToAreaPayload (
271+ fixturePayload (func (payload * iaas.AddRoutingTableToAreaPayload ) {
272+ payload .DynamicRoutes = utils .Ptr (false )
273+ }),
274+ )
271275 }),
272276 },
273277 }
@@ -314,32 +318,32 @@ func TestOutputResult(t *testing.T) {
314318 },
315319 {
316320 name : "empty routing-table" ,
317- outputFormat : "" ,
321+ outputFormat : print . PrettyOutputFormat ,
318322 routingTable : & iaas.RoutingTable {},
319323 wantErr : true ,
320324 },
321325 {
322- name : "table output routing-table" ,
323- outputFormat : "" ,
326+ name : "pretty output routing-table" ,
327+ outputFormat : print . PrettyOutputFormat ,
324328 routingTable : & dummyRoutingTable ,
325329 wantErr : false ,
326330 },
327331 {
328332 name : "json output routing-table" ,
329- outputFormat : pprint .JSONOutputFormat ,
333+ outputFormat : print .JSONOutputFormat ,
330334 routingTable : & dummyRoutingTable ,
331335 wantErr : false ,
332336 },
333337 {
334338 name : "yaml output routing-table" ,
335- outputFormat : pprint .YAMLOutputFormat ,
339+ outputFormat : print .YAMLOutputFormat ,
336340 routingTable : & dummyRoutingTable ,
337341 wantErr : false ,
338342 },
339343 }
340344
341- p := pprint .NewPrinter ()
342- p .Cmd = NewCmd (& params .CmdParams {Printer : p })
345+ p := print .NewPrinter ()
346+ p .Cmd = NewCmd (& types .CmdParams {Printer : p })
343347 for _ , tt := range tests {
344348 t .Run (tt .name , func (t * testing.T ) {
345349 if err := outputResult (p , tt .outputFormat , tt .routingTable ); (err != nil ) != tt .wantErr {
0 commit comments