Skip to content

Commit ddfb512

Browse files
authored
chore(config): Add nil pointer checks and tests for the outputResult functions (#621)
Signed-off-by: Alexander Dahmen <[email protected]>
1 parent a59b7e5 commit ddfb512

File tree

2 files changed

+69
-0
lines changed

2 files changed

+69
-0
lines changed

internal/cmd/config/list/list_test.go

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
package list
2+
3+
import (
4+
"testing"
5+
6+
"github.com/stackitcloud/stackit-cli/internal/pkg/print"
7+
)
8+
9+
func TestOutputResult(t *testing.T) {
10+
type args struct {
11+
outputFormat string
12+
configData map[string]any
13+
activeProfile string
14+
}
15+
tests := []struct {
16+
name string
17+
args args
18+
wantErr bool
19+
}{
20+
{
21+
name: "empty",
22+
args: args{},
23+
wantErr: false,
24+
},
25+
}
26+
p := print.NewPrinter()
27+
p.Cmd = NewCmd(p)
28+
for _, tt := range tests {
29+
t.Run(tt.name, func(t *testing.T) {
30+
if err := outputResult(p, tt.args.outputFormat, tt.args.configData, tt.args.activeProfile); (err != nil) != tt.wantErr {
31+
t.Errorf("outputResult() error = %v, wantErr %v", err, tt.wantErr)
32+
}
33+
})
34+
}
35+
}
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
package list
2+
3+
import (
4+
"testing"
5+
6+
"github.com/stackitcloud/stackit-cli/internal/pkg/print"
7+
)
8+
9+
func TestOutputResult(t *testing.T) {
10+
type args struct {
11+
outputFormat string
12+
profiles []profileInfo
13+
}
14+
tests := []struct {
15+
name string
16+
args args
17+
wantErr bool
18+
}{
19+
{
20+
name: "empty",
21+
args: args{},
22+
wantErr: false,
23+
},
24+
}
25+
p := print.NewPrinter()
26+
p.Cmd = NewCmd(p)
27+
for _, tt := range tests {
28+
t.Run(tt.name, func(t *testing.T) {
29+
if err := outputResult(p, tt.args.outputFormat, tt.args.profiles); (err != nil) != tt.wantErr {
30+
t.Errorf("outputResult() error = %v, wantErr %v", err, tt.wantErr)
31+
}
32+
})
33+
}
34+
}

0 commit comments

Comments
 (0)