Skip to content

Commit 42d1196

Browse files
committed
fix(cdn): make testNextPageID, testID and testStatus constant
1 parent a87cd60 commit 42d1196

File tree

1 file changed

+12
-8
lines changed

1 file changed

+12
-8
lines changed

internal/cmd/beta/cdn/distribution/list/list_test.go

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import (
1515
"github.com/stackitcloud/stackit-cli/internal/pkg/globalflags"
1616
"github.com/stackitcloud/stackit-cli/internal/pkg/print"
1717
"github.com/stackitcloud/stackit-cli/internal/pkg/testutils"
18+
"github.com/stackitcloud/stackit-cli/internal/pkg/utils"
1819
sdkConfig "github.com/stackitcloud/stackit-sdk-go/core/config"
1920
"github.com/stackitcloud/stackit-sdk-go/services/cdn"
2021
)
@@ -24,9 +25,12 @@ type testCtxKey struct{}
2425
var testProjectId = uuid.NewString()
2526
var testClient = &cdn.APIClient{}
2627
var testCtx = context.WithValue(context.Background(), testCtxKey{}, "foo")
27-
var testNextPageID = "next-page-id-123"
28-
var testID = "dist-1"
29-
var testStatus = cdn.DISTRIBUTIONSTATUS_ACTIVE
28+
29+
const (
30+
testNextPageID = "next-page-id-123"
31+
testID = "dist-1"
32+
testStatus = cdn.DISTRIBUTIONSTATUS_ACTIVE
33+
)
3034

3135
func fixtureFlagValues(mods ...func(flagValues map[string]string)) map[string]string {
3236
flagValues := map[string]string{
@@ -195,7 +199,7 @@ func TestBuildRequest(t *testing.T) {
195199
{
196200
description: "with next page id",
197201
inputModel: fixtureInputModel(),
198-
nextPageID: &testNextPageID,
202+
nextPageID: utils.Ptr(testNextPageID),
199203
expected: fixtureRequest(requestNextPageID(testNextPageID)),
200204
},
201205
}
@@ -281,7 +285,7 @@ func TestFetchDistributions(t *testing.T) {
281285
description: "multiple distributions, multiple pages",
282286
responses: []testResponse{
283287
fixtureTestResponse(
284-
responseNextPageID(&testNextPageID),
288+
responseNextPageID(utils.Ptr(testNextPageID)),
285289
responseDistributions(
286290
fixtureDistribution("dist-1"),
287291
),
@@ -310,7 +314,7 @@ func TestFetchDistributions(t *testing.T) {
310314
description: "API error on second page",
311315
responses: []testResponse{
312316
fixtureTestResponse(
313-
responseNextPageID(&testNextPageID),
317+
responseNextPageID(utils.Ptr(testNextPageID)),
314318
responseDistributions(
315319
fixtureDistribution("dist-1"),
316320
),
@@ -389,14 +393,14 @@ func TestOutputResult(t *testing.T) {
389393
outputFormat: "table",
390394
distributions: []cdn.Distribution{
391395
{
392-
Id: &testID,
396+
Id: utils.Ptr(testID),
393397
Config: &cdn.Config{
394398
Regions: &[]cdn.Region{
395399
cdn.REGION_EU,
396400
cdn.REGION_AF,
397401
},
398402
},
399-
Status: &testStatus,
403+
Status: utils.Ptr(testStatus),
400404
},
401405
},
402406
expected: `

0 commit comments

Comments
 (0)