Skip to content

Commit 49b7f97

Browse files
Revise boolean preservation test to trigger Update via request_max_bytes (#1163)
1 parent f1908bc commit 49b7f97

File tree

1 file changed

+19
-9
lines changed

1 file changed

+19
-9
lines changed

fastly/block_fastly_service_logging_kafka_test.go

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -236,40 +236,45 @@ func TestAccFastlyServiceLoggingKafka_compute_basic(t *testing.T) {
236236
})
237237
}
238238

239-
func TestAccFastlyServiceLoggingKafka_vcl_PreserveBooleansDuringNameChange(t *testing.T) {
239+
func TestAccFastlyServiceLoggingKafka_BooleanFieldsPreservedOnUpdate(t *testing.T) {
240240
var service gofastly.ServiceDetail
241241
serviceName := acctest.RandomWithPrefix("tf-kafka")
242242
domainName := fmt.Sprintf("test.%s.com", acctest.RandString(10))
243243

244-
initialKafkaName := "kafka-preserve"
245-
updatedKafkaName := "kafka-preserve-renamed"
244+
kafkaName := "kafka-logging-preserve"
246245

247-
// Values we want to preserve
248246
useTLS := true
249247
parseLogKeyvals := true
250248

249+
initialMaxBytes := 10000
250+
updatedMaxBytes := 20000
251+
251252
resource.ParallelTest(t, resource.TestCase{
252253
PreCheck: func() { testAccPreCheck(t) },
253254
ProviderFactories: testAccProviders,
254255
CheckDestroy: testAccCheckServiceVCLDestroy,
255256
Steps: []resource.TestStep{
256257
{
257-
Config: testAccServiceVCLKafkaLoggingPreserveBooleans(serviceName, domainName, initialKafkaName, useTLS, parseLogKeyvals),
258+
Config: testAccServiceVCLKafkaLoggingPreserveBooleansWithMaxBytes(
259+
serviceName, domainName, kafkaName, useTLS, parseLogKeyvals, initialMaxBytes),
258260
Check: resource.ComposeTestCheckFunc(
259261
testAccCheckServiceExists("fastly_service_vcl.foo", &service),
260262
resource.TestCheckResourceAttr("fastly_service_vcl.foo", "logging_kafka.#", "1"),
261263
resource.TestCheckResourceAttr("fastly_service_vcl.foo", "logging_kafka.0.use_tls", fmt.Sprintf("%t", useTLS)),
262264
resource.TestCheckResourceAttr("fastly_service_vcl.foo", "logging_kafka.0.parse_log_keyvals", fmt.Sprintf("%t", parseLogKeyvals)),
265+
resource.TestCheckResourceAttr("fastly_service_vcl.foo", "logging_kafka.0.request_max_bytes", fmt.Sprintf("%d", initialMaxBytes)),
263266
),
264267
},
265268
{
266-
// Only change the Kafka logging name (unrelated field), verify booleans are preserved
267-
Config: testAccServiceVCLKafkaLoggingPreserveBooleans(serviceName, domainName, updatedKafkaName, useTLS, parseLogKeyvals),
269+
// Only update non-ForceNew field: request_max_bytes
270+
Config: testAccServiceVCLKafkaLoggingPreserveBooleansWithMaxBytes(
271+
serviceName, domainName, kafkaName, useTLS, parseLogKeyvals, updatedMaxBytes),
268272
Check: resource.ComposeTestCheckFunc(
269273
testAccCheckServiceExists("fastly_service_vcl.foo", &service),
270274
resource.TestCheckResourceAttr("fastly_service_vcl.foo", "logging_kafka.#", "1"),
271275
resource.TestCheckResourceAttr("fastly_service_vcl.foo", "logging_kafka.0.use_tls", fmt.Sprintf("%t", useTLS)),
272276
resource.TestCheckResourceAttr("fastly_service_vcl.foo", "logging_kafka.0.parse_log_keyvals", fmt.Sprintf("%t", parseLogKeyvals)),
277+
resource.TestCheckResourceAttr("fastly_service_vcl.foo", "logging_kafka.0.request_max_bytes", fmt.Sprintf("%d", updatedMaxBytes)),
273278
),
274279
},
275280
},
@@ -492,7 +497,11 @@ resource "fastly_service_vcl" "foo" {
492497
}`, name, domain, format, format)
493498
}
494499

495-
func testAccServiceVCLKafkaLoggingPreserveBooleans(serviceName, domainName, kafkaName string, useTLS, parseLogKeyvals bool) string {
500+
func testAccServiceVCLKafkaLoggingPreserveBooleansWithMaxBytes(
501+
serviceName, domainName, kafkaName string,
502+
useTLS, parseLogKeyvals bool,
503+
requestMaxBytes int,
504+
) string {
496505
return fmt.Sprintf(`
497506
resource "fastly_service_vcl" "foo" {
498507
name = "%s"
@@ -514,9 +523,10 @@ resource "fastly_service_vcl" "foo" {
514523
required_acks = "1"
515524
use_tls = %t
516525
parse_log_keyvals = %t
526+
request_max_bytes = %d
517527
}
518528
519529
force_destroy = true
520530
}
521-
`, serviceName, domainName, kafkaName, useTLS, parseLogKeyvals)
531+
`, serviceName, domainName, kafkaName, useTLS, parseLogKeyvals, requestMaxBytes)
522532
}

0 commit comments

Comments
 (0)