@@ -4,13 +4,12 @@ import (
44 "context"
55 "testing"
66
7- "github.com/stackitcloud/stackit-cli/internal/pkg/globalflags"
8- "github.com/stackitcloud/stackit-cli/internal/pkg/print"
9- "github.com/stackitcloud/stackit-cli/internal/pkg/utils"
10-
117 "github.com/google/go-cmp/cmp"
128 "github.com/google/go-cmp/cmp/cmpopts"
139 "github.com/google/uuid"
10+ "github.com/stackitcloud/stackit-cli/internal/pkg/globalflags"
11+ "github.com/stackitcloud/stackit-cli/internal/pkg/print"
12+ "github.com/stackitcloud/stackit-cli/internal/pkg/utils"
1413 "github.com/stackitcloud/stackit-sdk-go/services/iaas"
1514)
1615
@@ -333,3 +332,40 @@ func TestBuildRequest(t *testing.T) {
333332 })
334333 }
335334}
335+
336+ func TestOutputResult (t * testing.T ) {
337+ type args struct {
338+ model * inputModel
339+ projectLabel string
340+ securityGroupName string
341+ securityGroupRule * iaas.SecurityGroupRule
342+ }
343+ tests := []struct {
344+ name string
345+ args args
346+ wantErr bool
347+ }{
348+ {
349+ name : "empty" ,
350+ args : args {},
351+ wantErr : true ,
352+ },
353+ {
354+ name : "only security group rule" ,
355+ args : args {
356+ model : fixtureInputModel (),
357+ securityGroupRule : & iaas.SecurityGroupRule {},
358+ },
359+ wantErr : false ,
360+ },
361+ }
362+ p := print .NewPrinter ()
363+ p .Cmd = NewCmd (p )
364+ for _ , tt := range tests {
365+ t .Run (tt .name , func (t * testing.T ) {
366+ if err := outputResult (p , tt .args .model , tt .args .projectLabel , tt .args .securityGroupName , tt .args .securityGroupRule ); (err != nil ) != tt .wantErr {
367+ t .Errorf ("outputResult() error = %v, wantErr %v" , err , tt .wantErr )
368+ }
369+ })
370+ }
371+ }
0 commit comments