@@ -242,6 +242,38 @@ func TestAccResourceTemplate_ProjectScopeImportFromGit(t *testing.T) {
242
242
})
243
243
}
244
244
245
+ func TestAccResourceTemplate_ProjectScopeImportFromGitNonDefaultBranch (t * testing.T ) {
246
+ id := "projecttemplate"
247
+ name := id
248
+ resourceName := "harness_platform_template.test"
249
+
250
+ resource .UnitTest (t , resource.TestCase {
251
+ PreCheck : func () { acctest .TestAccPreCheck (t ) },
252
+ ProviderFactories : acctest .ProviderFactories ,
253
+ ExternalProviders : map [string ]resource.ExternalProvider {
254
+ "time" : {},
255
+ "null" : {},
256
+ },
257
+ CheckDestroy : testAccTemplateDestroy (resourceName ),
258
+ Steps : []resource.TestStep {
259
+ {
260
+ Config : testAccResourceTemplateProjectScopeImportFromGitNonDefaultBranch (id , name ),
261
+ Check : resource .ComposeTestCheckFunc (
262
+ resource .TestCheckResourceAttr (resourceName , "id" , "projecttemplate" ),
263
+ resource .TestCheckResourceAttr (resourceName , "name" , "projecttemplate" ),
264
+ ),
265
+ },
266
+ {
267
+ ResourceName : resourceName ,
268
+ ImportState : true ,
269
+ ImportStateVerify : true ,
270
+ ImportStateIdFunc : acctest .ProjectResourceImportStateIdFunc (resourceName ),
271
+ ImportStateVerifyIgnore : []string {"git_details.0.commit_message" , "git_details.0.connector_ref" , "git_details.0.store_type" , "comments" , "git_details.0.branch_name" , "git_details.0.file_path" , "git_details.0.last_commit_id" , "git_details.0.repo_name" , "git_import_details.#" , "git_import_details.0.%" , "git_import_details.0.branch_name" , "git_import_details.0.connector_ref" , "git_import_details.0.file_path" , "git_import_details.0.is_force_import" , "git_import_details.0.repo_name" , "import_from_git" , "is_stable" , "template_import_request.#" , "template_import_request.0.%" , "template_import_request.0.template_description" , "template_import_request.0.template_name" , "template_import_request.0.template_version" , "template_yaml" , "version" , "git_details.0.last_object_id" },
272
+ },
273
+ },
274
+ })
275
+ }
276
+
245
277
func TestAccResourceTemplate_AccountScopeImportFromGit (t * testing.T ) {
246
278
id := "accounttemplate"
247
279
name := id
@@ -1443,6 +1475,40 @@ func testAccResourceTemplateProjectScopeImportFromGit(id string, name string) st
1443
1475
` , id , name )
1444
1476
}
1445
1477
1478
+ func testAccResourceTemplateProjectScopeImportFromGitNonDefaultBranch (id string , name string ) string {
1479
+ // This has project and org id static due to its config in the git.
1480
+ return fmt .Sprintf (`
1481
+ resource "harness_platform_template" "test" {
1482
+ identifier = "%[1]s"
1483
+ org_id = "default"
1484
+ project_id = "TF_Pipeline_Test"
1485
+ name = "%[2]s"
1486
+ version = "v2"
1487
+ import_from_git = true
1488
+ git_import_details {
1489
+ branch_name = "main-patch"
1490
+ file_path = ".harness/projecttemplate.yaml"
1491
+ connector_ref = "account.TF_open_repo_github_connector"
1492
+ repo_name = "open-repo"
1493
+ }
1494
+ template_import_request {
1495
+ template_name = "%[2]s"
1496
+ template_version = "v2"
1497
+ template_description = ""
1498
+ }
1499
+ }
1500
+
1501
+ resource "time_sleep" "wait_4_seconds" {
1502
+ depends_on = [harness_platform_template.test]
1503
+ destroy_duration = "4s"
1504
+ }
1505
+
1506
+ resource "null_resource" "next" {
1507
+ depends_on = [time_sleep.wait_4_seconds]
1508
+ }
1509
+ ` , id , name )
1510
+ }
1511
+
1446
1512
func testAccResourceTemplateAccountScopeImportFromGit (id string , name string ) string {
1447
1513
return fmt .Sprintf (`
1448
1514
resource "harness_platform_template" "test" {
0 commit comments