@@ -524,135 +524,54 @@ func TestHerokuBuildGeneration(t *testing.T) {
524524 }
525525}
526526
527- // TestAccHerokuBuild_Generation tests build generation validation with single space pattern
528- func TestAccHerokuBuild_Generation (t * testing.T ) {
529- var space spaceWithNAT
530- var cedarApp heroku.App
531- var firApp heroku.App
532- var cedarBuild heroku.Build
533- var firBuildValid heroku.Build
534-
535- spaceName := fmt .Sprintf ("tftest-build-gen-%s" , acctest .RandString (10 ))
536- cedarAppName := fmt .Sprintf ("tftest-cedar-build-%s" , acctest .RandString (10 ))
537- firAppName := fmt .Sprintf ("tftest-fir-build-%s" , acctest .RandString (10 ))
538- org := testAccConfig .GetAnyOrganizationOrSkip (t )
539-
540- resource .Test (t , resource.TestCase {
541- PreCheck : func () {
542- testAccPreCheck (t )
543- },
544- Providers : testAccProviders ,
545- CheckDestroy : testAccCheckHerokuSpaceDestroy ,
546- Steps : []resource.TestStep {
547- // Step 1: Create Fir space and Cedar app with build (should succeed)
548- {
549- Config : testAccCheckHerokuBuildConfig_generation_setup (spaceName , cedarAppName , firAppName , org ),
550- Check : resource .ComposeTestCheckFunc (
551- // Check space
552- testAccCheckHerokuSpaceExists ("heroku_space.fir_space" , & space ),
553- resource .TestCheckResourceAttr ("heroku_space.fir_space" , "generation" , "fir" ),
554- // Check Cedar app
555- testAccCheckHerokuAppExists ("heroku_app.cedar_app" , & cedarApp ),
556- resource .TestCheckResourceAttr ("heroku_app.cedar_app" , "generation" , "cedar" ),
557- // Check Fir app
558- testAccCheckHerokuAppExists ("heroku_app.fir_app" , & firApp ),
559- resource .TestCheckResourceAttr ("heroku_app.fir_app" , "generation" , "fir" ),
560- // Check Cedar build succeeds with buildpacks
561- testAccCheckHerokuBuildExists ("heroku_build.cedar_build" , & cedarBuild ),
562- resource .TestCheckResourceAttr ("heroku_build.cedar_build" , "status" , "succeeded" ),
563- // Check Fir build succeeds without buildpacks
564- testAccCheckHerokuBuildExists ("heroku_build.fir_build_valid" , & firBuildValid ),
565- resource .TestCheckResourceAttr ("heroku_build.fir_build_valid" , "status" , "succeeded" ),
566- ),
567- },
568- // Step 2: Try to create Fir build with buildpacks (should fail)
569- {
570- Config : testAccCheckHerokuBuildConfig_generation_fir_invalid (spaceName , cedarAppName , firAppName , org ),
571- ExpectError : regexp .MustCompile ("buildpacks cannot be specified for fir generation apps" ),
572- },
573- },
574- })
575- }
576-
577- // Configuration for generation testing setup (success cases)
578- func testAccCheckHerokuBuildConfig_generation_setup (spaceName , cedarAppName , firAppName , org string ) string {
579- return fmt .Sprintf (`
580- resource "heroku_space" "fir_space" {
581- name = "%s"
582- organization = "%s"
583- region = "virginia"
584- generation = "fir"
585- }
586-
587- resource "heroku_app" "cedar_app" {
588- name = "%s"
589- region = "us"
590- }
591-
592- resource "heroku_app" "fir_app" {
593- name = "%s"
594- region = heroku_space.fir_space.region
595- space = heroku_space.fir_space.id
527+ // testStep_AccHerokuBuild_Generation_FirValid tests that Fir builds work without buildpacks
528+ func testStep_AccHerokuBuild_Generation_FirValid (spaceConfig , spaceName string ) resource.TestStep {
529+ return resource.TestStep {
530+ Config : fmt .Sprintf (`
531+ %s
532+
533+ resource "heroku_app" "fir_build_app" {
534+ name = "tftest-fir-build-%s"
535+ region = heroku_space.foobar.region
536+ space = heroku_space.foobar.id
596537 organization {
597- name = "%s"
598- }
599- }
600-
601- resource "heroku_build" "cedar_build" {
602- app_id = heroku_app.cedar_app.id
603- buildpacks = ["https://github.com/heroku/heroku-buildpack-ruby.git"]
604-
605- source {
606- path = "test-fixtures/app"
538+ name = heroku_space.foobar.organization
607539 }
608540}
609541
610542resource "heroku_build" "fir_build_valid" {
611- app_id = heroku_app.fir_app .id
543+ app_id = heroku_app.fir_build_app .id
612544 # No buildpacks - should work with CNB
613545
614546 source {
615547 path = "test-fixtures/app"
616548 }
617549}
618- ` , spaceName , org , cedarAppName , firAppName , org )
619- }
620-
621- // Configuration for generation testing with invalid Fir build (failure case)
622- func testAccCheckHerokuBuildConfig_generation_fir_invalid (spaceName , cedarAppName , firAppName , org string ) string {
623- return fmt .Sprintf (`
624- resource "heroku_space" "fir_space" {
625- name = "%s"
626- organization = "%s"
627- region = "virginia"
628- generation = "fir"
550+ ` , spaceConfig , acctest .RandString (6 )),
551+ Check : resource .ComposeTestCheckFunc (
552+ resource .TestCheckResourceAttr ("heroku_app.fir_build_app" , "generation" , "fir" ),
553+ resource .TestCheckResourceAttr ("heroku_build.fir_build_valid" , "status" , "succeeded" ),
554+ ),
555+ }
629556}
630557
631- resource "heroku_app" "cedar_app" {
632- name = "%s"
633- region = "us"
634- }
558+ // testStep_AccHerokuBuild_Generation_FirInvalid tests that Fir builds fail with buildpacks
559+ func testStep_AccHerokuBuild_Generation_FirInvalid (spaceConfig , spaceName string ) resource.TestStep {
560+ return resource.TestStep {
561+ Config : fmt .Sprintf (`
562+ %s
635563
636- resource "heroku_app" "fir_app " {
637- name = "%s"
638- region = heroku_space.fir_space .region
639- space = heroku_space.fir_space .id
564+ resource "heroku_app" "fir_build_app " {
565+ name = "tftest-fir-build- %s"
566+ region = heroku_space.foobar .region
567+ space = heroku_space.foobar .id
640568 organization {
641- name = "%s"
642- }
643- }
644-
645- resource "heroku_build" "cedar_build" {
646- app_id = heroku_app.cedar_app.id
647- buildpacks = ["https://github.com/heroku/heroku-buildpack-ruby.git"]
648-
649- source {
650- path = "test-fixtures/app"
569+ name = heroku_space.foobar.organization
651570 }
652571}
653572
654573resource "heroku_build" "fir_build_valid" {
655- app_id = heroku_app.fir_app .id
574+ app_id = heroku_app.fir_build_app .id
656575 # No buildpacks - should work with CNB
657576
658577 source {
@@ -661,12 +580,14 @@ resource "heroku_build" "fir_build_valid" {
661580}
662581
663582resource "heroku_build" "fir_build_invalid" {
664- app_id = heroku_app.fir_app .id
665- buildpacks = ["https://github.com/ heroku/heroku-buildpack- nodejs.git "] # Should fail
583+ app_id = heroku_app.fir_build_app .id
584+ buildpacks = ["heroku/nodejs"] # Should fail
666585
667586 source {
668587 path = "test-fixtures/app"
669588 }
670589}
671- ` , spaceName , org , cedarAppName , firAppName , org )
590+ ` , spaceConfig , acctest .RandString (6 )),
591+ ExpectError : regexp .MustCompile ("buildpacks cannot be specified for fir generation apps" ),
592+ }
672593}
0 commit comments