@@ -2,6 +2,8 @@ package create
22
33import (
44 "context"
5+ "fmt"
6+ "strings"
57 "testing"
68
79 "github.com/stackitcloud/stackit-cli/internal/pkg/globalflags"
@@ -23,6 +25,12 @@ var testClient = &dns.APIClient{}
2325var testProjectId = uuid .NewString ()
2426var testZoneId = uuid .NewString ()
2527
28+ var recordTxtOver255Char = []string {
29+ "foobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoo" ,
30+ "foobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoo" ,
31+ "foobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobar" ,
32+ }
33+
2634func fixtureFlagValues (mods ... func (flagValues map [string ]string )) map [string ]string {
2735 flagValues := map [string ]string {
2836 projectIdFlag : testProjectId ,
@@ -326,6 +334,27 @@ func TestBuildRequest(t *testing.T) {
326334 Type : utils .Ptr (defaultType ),
327335 }),
328336 },
337+ {
338+ description : "add TXT record with > 255 characters" ,
339+ model : fixtureInputModel (func (model * inputModel ) {
340+ model .Type = txtType
341+ model .Records = []string {strings .Join (recordTxtOver255Char , "" )}
342+ }),
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+ ),
351+ },
352+ },
353+ Type : utils .Ptr (txtType ),
354+ Comment : utils .Ptr ("comment" ),
355+ Ttl : utils .Ptr (int64 (3600 )),
356+ }),
357+ },
329358 }
330359
331360 for _ , tt := range tests {
0 commit comments