Skip to content

Commit 4c27f7d

Browse files
committed
JoinQuotedStrings
1 parent a2be534 commit 4c27f7d

File tree

3 files changed

+17
-9
lines changed

3 files changed

+17
-9
lines changed

internal/service/advancedcluster/resource_advanced_cluster_test.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -2109,8 +2109,8 @@ func configAdvanced(t *testing.T, usePreviewProvider bool, projectID, clusterNam
21092109
tlsCipherConfigModeStr = fmt.Sprintf(`tls_cipher_config_mode = %[1]q`, *p.TlsCipherConfigMode)
21102110
if p.CustomOpensslCipherConfigTls12 != nil && len(*p.CustomOpensslCipherConfigTls12) > 0 {
21112111
customOpensslCipherConfigTLS12Str = fmt.Sprintf(
2112-
`custom_openssl_cipher_config_tls12 = [%q]`,
2113-
strings.Join(*p.CustomOpensslCipherConfigTls12, `", "`),
2112+
`custom_openssl_cipher_config_tls12 = [%s]`,
2113+
acc.JoinQuotedStrings(*p.CustomOpensslCipherConfigTls12),
21142114
)
21152115
}
21162116
}

internal/service/cluster/resource_cluster_test.go

+6-7
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import (
44
"fmt"
55
"os"
66
"regexp"
7-
"strings"
87
"testing"
98
"time"
109

@@ -1473,8 +1472,8 @@ func configAdvancedConf(projectID, name, autoscalingEnabled string,
14731472
tlsCipherConfigModeStr = fmt.Sprintf(`tls_cipher_config_mode = %[1]q`, *p.TlsCipherConfigMode)
14741473
if p.CustomOpensslCipherConfigTls12 != nil && len(*p.CustomOpensslCipherConfigTls12) > 0 {
14751474
customOpensslCipherConfigTLS12Str = fmt.Sprintf(
1476-
`custom_openssl_cipher_config_tls12 = [%q]`,
1477-
strings.Join(*p.CustomOpensslCipherConfigTls12, `", "`),
1475+
`custom_openssl_cipher_config_tls12 = [%s]`,
1476+
acc.JoinQuotedStrings(*p.CustomOpensslCipherConfigTls12),
14781477
)
14791478
}
14801479
}
@@ -1577,8 +1576,8 @@ func configAdvancedConfPartial(projectID, name, autoscalingEnabled string, p *ad
15771576
tlsCipherConfigModeStr = fmt.Sprintf(`tls_cipher_config_mode = %[1]q`, *p.TlsCipherConfigMode)
15781577
if p.CustomOpensslCipherConfigTls12 != nil && len(*p.CustomOpensslCipherConfigTls12) > 0 {
15791578
customOpensslCipherConfigTLS12Str = fmt.Sprintf(
1580-
`custom_openssl_cipher_config_tls12 = [%q]`,
1581-
strings.Join(*p.CustomOpensslCipherConfigTls12, `", "`),
1579+
`custom_openssl_cipher_config_tls12 = [%s]`,
1580+
acc.JoinQuotedStrings(*p.CustomOpensslCipherConfigTls12),
15821581
)
15831582
}
15841583
}
@@ -1898,8 +1897,8 @@ func testAccMongoDBAtlasClusterAWSConfigdWithLabels(projectID, name, backupEnabl
18981897
for _, label := range labels {
18991898
labelsConf += fmt.Sprintf(`
19001899
labels {
1901-
key = "%s"
1902-
value = "%s"
1900+
key = %q
1901+
value = %q
19031902
}
19041903
`, label.Key, label.Value)
19051904
}

internal/testutil/acc/advanced_cluster.go

+9
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package acc
33
import (
44
"context"
55
"fmt"
6+
"strings"
67
"time"
78

89
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/retry"
@@ -193,3 +194,11 @@ func PopulateWithSampleData(projectID, clusterName string) error {
193194
_, err = stateConf.WaitForStateContext(ctx)
194195
return err
195196
}
197+
198+
func JoinQuotedStrings(list []string) string {
199+
quoted := make([]string, len(list))
200+
for i, item := range list {
201+
quoted[i] = fmt.Sprintf("%q", item)
202+
}
203+
return strings.Join(quoted, ", ")
204+
}

0 commit comments

Comments
 (0)