diff --git a/octopusdeploy/resource_project_test.go b/octopusdeploy/resource_project_test.go index a4ba88b25..6ef08c71b 100644 --- a/octopusdeploy/resource_project_test.go +++ b/octopusdeploy/resource_project_test.go @@ -15,7 +15,6 @@ func TestAccOctopusDeployProjectBasic(t *testing.T) { const terraformNamePrefix = "octopusdeploy_project.foo" const projectName = "Funky Monkey" const lifeCycleID = "Lifecycles-1" - const projectGroupID = "ProjectGroups-1" const allowDeploymentsToNoTargets = "true" resource.Test(t, resource.TestCase{ PreCheck: func() { testAccPreCheck(t) }, @@ -23,15 +22,13 @@ func TestAccOctopusDeployProjectBasic(t *testing.T) { CheckDestroy: testAccCheckOctopusDeployProjectDestroy, Steps: []resource.TestStep{ { - Config: testAccProjectBasic(projectName, lifeCycleID, projectGroupID, allowDeploymentsToNoTargets), + Config: testAccProjectBasic(projectName, lifeCycleID, allowDeploymentsToNoTargets), Check: resource.ComposeTestCheckFunc( testAccCheckOctopusDeployProjectExists(terraformNamePrefix), resource.TestCheckResourceAttr( terraformNamePrefix, "name", projectName), resource.TestCheckResourceAttr( terraformNamePrefix, "lifecycle_id", lifeCycleID), - resource.TestCheckResourceAttr( - terraformNamePrefix, "project_group_id", projectGroupID), resource.TestCheckResourceAttr( terraformNamePrefix, "allow_deployments_to_no_targets", allowDeploymentsToNoTargets), ), @@ -44,7 +41,6 @@ func TestAccOctopusDeployProjectWithDeploymentStepWindowsService(t *testing.T) { const terraformNamePrefix = "octopusdeploy_project.foo" const projectName = "Funky Monkey" const lifeCycleID = "Lifecycles-1" - const projectGroupID = "ProjectGroups-1" const serviceName = "Epic Service" const executablePath = `bin\\MyService.exe` // needs 4 slashes to appear in the TF config as a double slash const stepName = "Deploying Epic Service" @@ -59,7 +55,7 @@ func TestAccOctopusDeployProjectWithDeploymentStepWindowsService(t *testing.T) { CheckDestroy: testAccCheckOctopusDeployProjectDestroy, Steps: []resource.TestStep{ { - Config: testAccWithDeploymentStepWindowsService(projectName, lifeCycleID, projectGroupID, serviceName, executablePath, stepName, packageName, targetRoles), + Config: testAccWithDeploymentStepWindowsService(projectName, lifeCycleID, serviceName, executablePath, stepName, packageName, targetRoles), Check: resource.ComposeTestCheckFunc( testAccCheckOctopusDeployProjectExists(terraformNamePrefix), resource.TestMatchResourceAttr( @@ -68,8 +64,6 @@ func TestAccOctopusDeployProjectWithDeploymentStepWindowsService(t *testing.T) { terraformNamePrefix, "name", projectName), resource.TestCheckResourceAttr( terraformNamePrefix, "lifecycle_id", lifeCycleID), - resource.TestCheckResourceAttr( - terraformNamePrefix, "project_group_id", projectGroupID), resource.TestCheckResourceAttr( terraformNamePrefix, "deployment_step_windows_service.0.service_name", serviceName), resource.TestCheckResourceAttr( @@ -92,8 +86,6 @@ func TestAccOctopusDeployProjectWithUpdate(t *testing.T) { const terraformNamePrefix = "octopusdeploy_project.foo" const projectName = "Funky Monkey" const lifeCycleID = "Lifecycles-1" - const projectGroupID = "ProjectGroups-1" - const description = "I am a new description" const allowDeploymentsToNoTargets = "true" inlineScriptRegex := regexp.MustCompile(".*Get\\-Process.*") resource.Test(t, resource.TestCase{ @@ -103,15 +95,13 @@ func TestAccOctopusDeployProjectWithUpdate(t *testing.T) { Steps: []resource.TestStep{ // create project with no description { - Config: testAccProjectBasic(projectName, lifeCycleID, projectGroupID, allowDeploymentsToNoTargets), + Config: testAccProjectBasic(projectName, lifeCycleID, allowDeploymentsToNoTargets), Check: resource.ComposeTestCheckFunc( testAccCheckOctopusDeployProjectExists(terraformNamePrefix), resource.TestCheckResourceAttr( terraformNamePrefix, "name", projectName), resource.TestCheckResourceAttr( terraformNamePrefix, "lifecycle_id", lifeCycleID), - resource.TestCheckResourceAttr( - terraformNamePrefix, "project_group_id", projectGroupID), ), }, // create update it with a description + build steps @@ -123,8 +113,6 @@ func TestAccOctopusDeployProjectWithUpdate(t *testing.T) { terraformNamePrefix, "name", "Project Name"), resource.TestCheckResourceAttr( terraformNamePrefix, "lifecycle_id", "Lifecycles-1"), - resource.TestCheckResourceAttr( - terraformNamePrefix, "project_group_id", "ProjectGroups-1"), resource.TestCheckResourceAttr( terraformNamePrefix, "description", "My Awesome Description"), resource.TestCheckResourceAttr( @@ -201,15 +189,13 @@ func TestAccOctopusDeployProjectWithUpdate(t *testing.T) { }, // update again by remove its description { - Config: testAccProjectBasic(projectName, lifeCycleID, projectGroupID, allowDeploymentsToNoTargets), + Config: testAccProjectBasic(projectName, lifeCycleID, allowDeploymentsToNoTargets), Check: resource.ComposeTestCheckFunc( testAccCheckOctopusDeployProjectExists(terraformNamePrefix), resource.TestCheckResourceAttr( terraformNamePrefix, "name", projectName), resource.TestCheckResourceAttr( terraformNamePrefix, "lifecycle_id", lifeCycleID), - resource.TestCheckResourceAttr( - terraformNamePrefix, "project_group_id", projectGroupID), resource.TestCheckResourceAttr( terraformNamePrefix, "description", ""), resource.TestCheckNoResourceAttr( @@ -224,7 +210,7 @@ func TestAccOctopusDeployProjectWithUpdate(t *testing.T) { }) } -func testAccProjectBasic(name, lifeCycleID, projectGroupID string, allowDeploymentsToNoTargets string) string { +func testAccProjectBasic(name, lifeCycleID, allowDeploymentsToNoTargets string) string { return fmt.Sprintf(` resource "octopusdeploy_project_group" "foo" { name = "Integration Test Project Group" @@ -233,11 +219,11 @@ func testAccProjectBasic(name, lifeCycleID, projectGroupID string, allowDeployme resource "octopusdeploy_project" "foo" { name = "%s" lifecycle_id = "%s" - project_group_id = "%s" + project_group_id = "${octopusdeploy_project_group.foo.id}" allow_deployments_to_no_targets = "%s" } `, - name, lifeCycleID, projectGroupID, allowDeploymentsToNoTargets, + name, lifeCycleID, allowDeploymentsToNoTargets, ) } @@ -327,12 +313,17 @@ resource "octopusdeploy_project" "foo" { } ` -func testAccWithDeploymentStepWindowsService(name, lifeCycleID, projectGroupID, serviceName, executablePath, stepName, packageName string, targetRoles []string) string { +func testAccWithDeploymentStepWindowsService(name, lifeCycleID, serviceName, executablePath, stepName, packageName string, targetRoles []string) string { return fmt.Sprintf(` + + resource "octopusdeploy_project_group" "foo" { + name = "Integration Test Project Group" + } + resource "octopusdeploy_project" "foo" { name = "%s" lifecycle_id = "%s" - project_group_id = "%s" + project_group_id = "${octopusdeploy_project_group.foo.id}" deployment_step_windows_service { executable_path = "%s" @@ -346,7 +337,7 @@ func testAccWithDeploymentStepWindowsService(name, lifeCycleID, projectGroupID, } } `, - name, lifeCycleID, projectGroupID, executablePath, serviceName, stepName, packageName, strings.Join(targetRoles, "\",\""), + name, lifeCycleID, executablePath, serviceName, stepName, packageName, strings.Join(targetRoles, "\",\""), ) }