Skip to content

Commit 4e34aab

Browse files
philrossFyusel
authored andcommitted
fix: use utils.Ptr()
1 parent 053940e commit 4e34aab

2 files changed

Lines changed: 7 additions & 13 deletions

File tree

internal/cmd/auth/activate-service-account/activate_service_account_test.go

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import (
44
"testing"
55

66
"github.com/stackitcloud/stackit-cli/internal/pkg/testutils"
7+
"github.com/stackitcloud/stackit-cli/internal/pkg/utils"
78

89
"github.com/spf13/viper"
910
"github.com/zalando/go-keyring"
@@ -14,10 +15,6 @@ import (
1415

1516
var testTokenCustomEndpoint = "token_url"
1617

17-
func boolPtr(v bool) *bool {
18-
return &v
19-
}
20-
2118
func fixtureFlagValues(mods ...func(flagValues map[string]string)) map[string]string {
2219
flagValues := map[string]string{
2320
serviceAccountTokenFlag: "token",
@@ -37,7 +34,7 @@ func fixtureInputModel(mods ...func(model *inputModel)) *inputModel {
3734
ServiceAccountToken: "token",
3835
ServiceAccountKeyPath: "sa_key",
3936
PrivateKeyPath: "private_key",
40-
UseOIDC: boolPtr(true),
37+
UseOIDC: utils.Ptr(true),
4138
OnlyPrintAccessToken: true,
4239
}
4340
for _, mod := range mods {
@@ -97,7 +94,7 @@ func TestParseInput(t *testing.T) {
9794
}),
9895
isValid: true,
9996
expectedModel: fixtureInputModel(func(model *inputModel) {
100-
model.UseOIDC = boolPtr(true)
97+
model.UseOIDC = utils.Ptr(true)
10198
}),
10299
},
103100
{
@@ -107,7 +104,7 @@ func TestParseInput(t *testing.T) {
107104
}),
108105
isValid: true,
109106
expectedModel: fixtureInputModel(func(model *inputModel) {
110-
model.UseOIDC = boolPtr(false)
107+
model.UseOIDC = utils.Ptr(false)
111108
}),
112109
},
113110
{

internal/pkg/auth/oidc_test.go

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,9 @@ import (
88
"testing"
99

1010
"github.com/stackitcloud/stackit-cli/internal/pkg/auth"
11+
"github.com/stackitcloud/stackit-cli/internal/pkg/utils"
1112
)
1213

13-
func boolPtr(v bool) *bool {
14-
return &v
15-
}
16-
1714
func TestIsEnabled(t *testing.T) {
1815
tests := []struct {
1916
value string
@@ -61,13 +58,13 @@ func TestIsOIDCEnabledWithOverride(t *testing.T) {
6158
{
6259
description: "override true wins over env false",
6360
envUseOIDC: "0",
64-
override: boolPtr(true),
61+
override: utils.Ptr(true),
6562
expected: true,
6663
},
6764
{
6865
description: "override false wins over env true",
6966
envUseOIDC: "1",
70-
override: boolPtr(false),
67+
override: utils.Ptr(false),
7168
expected: false,
7269
},
7370
}

0 commit comments

Comments
 (0)