@@ -23,6 +23,7 @@ func TestAccEventarcMessageBus(t *testing.T) {
2323 "cryptoKey" : testAccEventarcMessageBus_cryptoKey ,
2424 "update" : testAccEventarcMessageBus_update ,
2525 "googleApiSource" : testAccEventarcMessageBus_googleApiSource ,
26+ "pipeline" : testAccEventarcMessageBus_pipeline ,
2627 }
2728
2829 for name , tc := range testCases {
@@ -286,14 +287,61 @@ resource "google_eventarc_google_api_source" "primary" {
286287 log_severity = "DEBUG"
287288 }
288289}
289-
290290resource "google_eventarc_message_bus" "message_bus" {
291291 location = "%{region}"
292292 message_bus_id = "tf-test-messagebus%{random_suffix}"
293293}
294294` , context )
295295}
296296
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+
297345func testAccCheckEventarcMessageBusDestroyProducer (t * testing.T ) func (s * terraform.State ) error {
298346 return func (s * terraform.State ) error {
299347 for name , rs := range s .RootModule ().Resources {
0 commit comments