Skip to content

Commit 602c42f

Browse files
committed
fix: linter issues
1 parent cef3893 commit 602c42f

File tree

4 files changed

+47
-29
lines changed

4 files changed

+47
-29
lines changed

internal/cmd/dns/record-set/create/create.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ import (
44
"context"
55
"encoding/json"
66
"fmt"
7+
"math"
8+
79
"github.com/goccy/go-yaml"
810
"github.com/stackitcloud/stackit-cli/internal/pkg/args"
911
"github.com/stackitcloud/stackit-cli/internal/pkg/errors"
@@ -15,7 +17,6 @@ import (
1517
dnsUtils "github.com/stackitcloud/stackit-cli/internal/pkg/services/dns/utils"
1618
"github.com/stackitcloud/stackit-cli/internal/pkg/spinner"
1719
"github.com/stackitcloud/stackit-cli/internal/pkg/utils"
18-
"math"
1920

2021
"github.com/spf13/cobra"
2122
"github.com/stackitcloud/stackit-sdk-go/services/dns"

internal/cmd/dns/record-set/create/create_test.go

Lines changed: 21 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -340,20 +340,28 @@ func TestBuildRequest(t *testing.T) {
340340
model.Type = txtType
341341
model.Records = []string{strings.Join(recordTxtOver255Char, "")}
342342
}),
343-
expectedRequest: testClient.CreateRecordSet(testCtx, testProjectId, testZoneId).
344-
CreateRecordSetPayload(dns.CreateRecordSetPayload{
345-
Name: utils.Ptr("example.com"),
346-
Records: &[]dns.RecordPayload{
347-
{
348-
Content: utils.Ptr(
349-
fmt.Sprintf("\"%s\"", strings.Join(recordTxtOver255Char, "\" \"")),
350-
),
343+
expectedRequest: func() dns.ApiCreateRecordSetRequest {
344+
var content string
345+
for idx, val := range recordTxtOver255Char {
346+
content += fmt.Sprintf("%q", val)
347+
if idx != len(recordTxtOver255Char)-1 {
348+
content += " "
349+
}
350+
}
351+
352+
return testClient.CreateRecordSet(testCtx, testProjectId, testZoneId).
353+
CreateRecordSetPayload(dns.CreateRecordSetPayload{
354+
Name: utils.Ptr("example.com"),
355+
Records: &[]dns.RecordPayload{
356+
{
357+
Content: utils.Ptr(content),
358+
},
351359
},
352-
},
353-
Type: utils.Ptr(txtType),
354-
Comment: utils.Ptr("comment"),
355-
Ttl: utils.Ptr(int64(3600)),
356-
}),
360+
Type: utils.Ptr(txtType),
361+
Comment: utils.Ptr("comment"),
362+
Ttl: utils.Ptr(int64(3600)),
363+
})
364+
}(),
357365
},
358366
}
359367

internal/cmd/dns/record-set/update/update_test.go

Lines changed: 23 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -86,10 +86,11 @@ func fixtureRequest(mods ...func(request *dns.ApiPartialUpdateRecordSetRequest))
8686
},
8787
Ttl: utils.Ptr(int64(3600)),
8888
})
89+
req := &request
8990
for _, mod := range mods {
90-
mod(&request)
91+
mod(req)
9192
}
92-
return request
93+
return *req
9394
}
9495

9596
func TestParseInput(t *testing.T) {
@@ -344,19 +345,27 @@ func TestBuildRequest(t *testing.T) {
344345
model.Type = utils.Ptr(txtType)
345346
model.Records = utils.Ptr([]string{strings.Join(recordTxtOver255Char, "")})
346347
}),
347-
expectedRequest: testClient.PartialUpdateRecordSet(testCtx, testProjectId, testZoneId, testRecordSetId).
348-
PartialUpdateRecordSetPayload(dns.PartialUpdateRecordSetPayload{
349-
Name: utils.Ptr("example.com"),
350-
Records: &[]dns.RecordPayload{
351-
{
352-
Content: utils.Ptr(
353-
fmt.Sprintf("\"%s\"", strings.Join(recordTxtOver255Char, "\" \"")),
354-
),
348+
expectedRequest: func() dns.ApiPartialUpdateRecordSetRequest {
349+
var content string
350+
for idx, val := range recordTxtOver255Char {
351+
content += fmt.Sprintf("%q", val)
352+
if idx != len(recordTxtOver255Char)-1 {
353+
content += " "
354+
}
355+
}
356+
357+
return testClient.PartialUpdateRecordSet(testCtx, testProjectId, testZoneId, testRecordSetId).
358+
PartialUpdateRecordSetPayload(dns.PartialUpdateRecordSetPayload{
359+
Name: utils.Ptr("example.com"),
360+
Records: &[]dns.RecordPayload{
361+
{
362+
Content: utils.Ptr(content),
363+
},
355364
},
356-
},
357-
Comment: utils.Ptr("comment"),
358-
Ttl: utils.Ptr(int64(3600)),
359-
}),
365+
Comment: utils.Ptr("comment"),
366+
Ttl: utils.Ptr(int64(3600)),
367+
})
368+
}(),
360369
},
361370
}
362371

internal/pkg/services/dns/utils/utils.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ package utils
33
import (
44
"context"
55
"fmt"
6-
"github.com/stackitcloud/stackit-cli/internal/pkg/utils"
76

7+
"github.com/stackitcloud/stackit-cli/internal/pkg/utils"
88
"github.com/stackitcloud/stackit-sdk-go/services/dns"
99
)
1010

0 commit comments

Comments
 (0)