@@ -23,6 +23,7 @@ func TestAccEventarcMessageBus(t *testing.T) {
23
23
"cryptoKey" : testAccEventarcMessageBus_cryptoKey ,
24
24
"update" : testAccEventarcMessageBus_update ,
25
25
"googleApiSource" : testAccEventarcMessageBus_googleApiSource ,
26
+ "pipeline" : testAccEventarcMessageBus_pipeline ,
26
27
}
27
28
28
29
for name , tc := range testCases {
@@ -286,14 +287,61 @@ resource "google_eventarc_google_api_source" "primary" {
286
287
log_severity = "DEBUG"
287
288
}
288
289
}
289
-
290
290
resource "google_eventarc_message_bus" "message_bus" {
291
291
location = "%{region}"
292
292
message_bus_id = "tf-test-messagebus%{random_suffix}"
293
293
}
294
294
` , context )
295
295
}
296
296
297
+ // Although this test is defined in resource_eventarc_message_bus_test, it is primarily
298
+ // concerned with testing the Pipeline resource, which depends on a singleton MessageBus.
299
+ func testAccEventarcMessageBus_pipeline (t * testing.T ) {
300
+ context := map [string ]interface {}{
301
+ "project_id" : envvar .GetTestProjectFromEnv (),
302
+ "region" : envvar .GetTestRegionFromEnv (),
303
+ "random_suffix" : acctest .RandString (t , 10 ),
304
+ "network_attachment_name" : acctest .BootstrapNetworkAttachment (t , "tf-test-eventarc-messagebus-na" , acctest .BootstrapSubnet (t , "tf-test-eventarc-messagebus-subnet" , acctest .BootstrapSharedTestNetwork (t , "tf-test-eventarc-messagebus-network" ))),
305
+ }
306
+
307
+ acctest .VcrTest (t , resource.TestCase {
308
+ PreCheck : func () { acctest .AccTestPreCheck (t ) },
309
+ ProtoV5ProviderFactories : acctest .ProtoV5ProviderFactories (t ),
310
+ CheckDestroy : testAccCheckEventarcPipelineDestroyProducer (t ),
311
+ Steps : []resource.TestStep {
312
+ {
313
+ Config : testAccEventarcMessageBus_pipelineCfg (context ),
314
+ },
315
+ {
316
+ ResourceName : "google_eventarc_pipeline.primary" ,
317
+ ImportState : true ,
318
+ ImportStateVerify : true ,
319
+ ImportStateVerifyIgnore : []string {"labels" , "terraform_labels" , "annotations" },
320
+ },
321
+ },
322
+ })
323
+ }
324
+
325
+ func testAccEventarcMessageBus_pipelineCfg (context map [string ]interface {}) string {
326
+ return acctest .Nprintf (`
327
+ resource "google_eventarc_pipeline" "primary" {
328
+ location = "%{region}"
329
+ pipeline_id = "tf-test-some-pipeline%{random_suffix}"
330
+ destinations {
331
+ message_bus = google_eventarc_message_bus.primary.id
332
+ network_config {
333
+ network_attachment = "projects/%{project_id}/regions/%{region}/networkAttachments/%{network_attachment_name}"
334
+ }
335
+ }
336
+ }
337
+
338
+ resource "google_eventarc_message_bus" "primary" {
339
+ location = "%{region}"
340
+ message_bus_id = "tf-test-messagebus%{random_suffix}"
341
+ }
342
+ ` , context )
343
+ }
344
+
297
345
func testAccCheckEventarcMessageBusDestroyProducer (t * testing.T ) func (s * terraform.State ) error {
298
346
return func (s * terraform.State ) error {
299
347
for name , rs := range s .RootModule ().Resources {
0 commit comments