Skip to content

Commit

Permalink
skip test due to missing functionality
Browse files Browse the repository at this point in the history
  • Loading branch information
benPearce1 committed Dec 2, 2024
1 parent 2806290 commit 8ef300d
Showing 1 changed file with 41 additions and 52 deletions.
93 changes: 41 additions & 52 deletions octopusdeploy_framework/resource_deployment_freeze_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,22 @@ import (
"github.com/hashicorp/terraform-plugin-testing/helper/acctest"
"github.com/hashicorp/terraform-plugin-testing/helper/resource"
"github.com/hashicorp/terraform-plugin-testing/terraform"
"strings"
"testing"
"time"
)

func TestNewDeploymentFreezeResource(t *testing.T) {
t.Skip("this test relies on changes in 2025.1.1728+ and will need to be skipped until that is the latest on the container feed")
localName := acctest.RandStringFromCharSet(20, acctest.CharSetAlpha)
resourceName := "octopusdeploy_deployment_freeze." + localName
name := acctest.RandStringFromCharSet(20, acctest.CharSetAlpha)
start := fmt.Sprintf("%d-11-21T06:30:00+10:00", time.Now().Year()+1)
end := fmt.Sprintf("%d-11-21T08:30:00+10:00", time.Now().Year()+1)
updatedEnd := fmt.Sprintf("%d-11-21T08:30:00+10:00", time.Now().Year()+2)
projectName := acctest.RandStringFromCharSet(20, acctest.CharSetAlpha)
environmentName := acctest.RandStringFromCharSet(20, acctest.CharSetAlpha)
environmentName1 := acctest.RandStringFromCharSet(20, acctest.CharSetAlpha)
environmentName2 := acctest.RandStringFromCharSet(20, acctest.CharSetAlpha)
spaceName := acctest.RandStringFromCharSet(20, acctest.CharSetAlpha)
projectGroupName := acctest.RandStringFromCharSet(20, acctest.CharSetAlpha)
lifecycleName := acctest.RandStringFromCharSet(20, acctest.CharSetAlpha)
Expand All @@ -34,79 +37,65 @@ func TestNewDeploymentFreezeResource(t *testing.T) {
resource.TestCheckResourceAttr(resourceName, "name", name),
resource.TestCheckResourceAttr(resourceName, "start", start),
resource.TestCheckResourceAttr(resourceName, "end", end)),
Config: testDeploymentFreezeBasic(localName, name, start, end, spaceName, environmentName, projectName, projectGroupName, lifecycleName),
Config: testDeploymentFreezeBasic(localName, name, start, end, spaceName, []string{environmentName1}, projectName, projectGroupName, lifecycleName),
},
{
Check: resource.ComposeTestCheckFunc(
testDeploymentFreezeExists(resourceName),
resource.TestCheckResourceAttr(resourceName, "name", name+"1"),
resource.TestCheckResourceAttr(resourceName, "start", start),
resource.TestCheckResourceAttr(resourceName, "end", updatedEnd)),
Config: testDeploymentFreezeBasic(localName, name+"1", start, updatedEnd, spaceName, environmentName, projectName, projectGroupName, lifecycleName),
Config: testDeploymentFreezeBasic(localName, name+"1", start, updatedEnd, spaceName, []string{environmentName1, environmentName2}, projectName, projectGroupName, lifecycleName),
},
},
})
}

func testDeploymentFreezeBasic(localName string, freezeName string, start string, end string, spaceName string, environmentName string, projectName string, projectGroupName string, lifecycleName string) string {
func testDeploymentFreezeBasic(localName string, freezeName string, start string, end string, spaceName string, environments []string, projectName string, projectGroupName string, lifecycleName string) string {
spaceLocalName := fmt.Sprintf("space_%s", localName)
projectScopeLocalName := fmt.Sprintf("project_scope_%s", localName)
projectLocalName := fmt.Sprintf("project_%s", localName)
lifecycleLocalName := fmt.Sprintf("lifecycle_%s", localName)
projectGroupLocalName := fmt.Sprintf("project_group_%s", localName)
environmentScopes := make([]string, 0, len(environments))
environmentResources := ""
for i, environmentName := range environments {
environmentLocalName := fmt.Sprintf("environment_%d_%s", i, localName)
environmentResources += fmt.Sprintln(createEnvironment(spaceLocalName, environmentLocalName, environmentName))
environmentScopes = append(environmentScopes, fmt.Sprintf("resource.octopusdeploy_environment.%s.id", environmentLocalName))
}

projectScopes := fmt.Sprintf(`resource "octopusdeploy_deployment_freeze_project" "%s" {
deploymentfreeze_id = octopusdeploy_deployment_freeze.%s.id
project_id = octopusdeploy_project.%s.id
environment_ids = [ %s ]
}`, projectScopeLocalName, localName, projectLocalName, strings.Join(environmentScopes, ","))

return fmt.Sprintf(`
%s
%s
%s
%s
%s
resource "octopusdeploy_deployment_freeze" "%s" {
name = "%s"
start = "%s"
end = "%s"
}`,
createSpace(spaceLocalName, spaceName), localName, freezeName, start, end)
}
}
//func testDeploymentFreezeBasic(localName string, freezeName string, start string, end string, spaceName string, environments []string, projectName string, projectGroupName string, lifecycleName string) string {
// spaceLocalName := fmt.Sprintf("space_%s", localName)
// projectScopeLocalName := fmt.Sprintf("project_scope_%s", localName)
// projectLocalName := fmt.Sprintf("project_%s", localName)
// lifecycleLocalName := fmt.Sprintf("lifecycle_%s", localName)
// projectGroupLocalName := fmt.Sprintf("project_group_%s", localName)
// environmentScopes := make([]string, 0, len(environments))
// environmentResources := ""
// for i, environmentName := range environments {
// environmentLocalName := fmt.Sprintf("environment_%d_%s", i, localName)
// environmentResources += fmt.Sprintln(createEnvironment(spaceLocalName, environmentLocalName, environmentName))
// environmentScopes = append(environmentScopes, fmt.Sprintf("resource.octopusdeploy_environment.%s.id", environmentLocalName))
// }
//
// projectScopes := fmt.Sprintf(`resource "octopusdeploy_deployment_freeze_project" "%s" {
// deploymentfreeze_id = octopusdeploy_deployment_freeze.%s.id
// project_id = octopusdeploy_project.%s.id
// environment_ids = [ %s ]
// }`, projectScopeLocalName, localName, projectLocalName, strings.Join(environmentScopes, ","))
//
// return fmt.Sprintf(`
// %s
//
// %s
//
// %s
//
// %s
//
// %s
//
// resource "octopusdeploy_deployment_freeze" "%s" {
// name = "%s"
// start = "%s"
// end = "%s"
// }
//
// %s`,
// createSpace(spaceLocalName, spaceName),
// environmentResources,
// createLifecycle(spaceLocalName, lifecycleLocalName, lifecycleName),
// createProjectGroup(spaceLocalName, projectGroupLocalName, projectGroupName),
// createProject(spaceLocalName, projectLocalName, projectName, lifecycleLocalName, projectGroupLocalName),
// localName, freezeName, start, end, projectScopes)
//}
%s`,
createSpace(spaceLocalName, spaceName),
environmentResources,
createLifecycle(spaceLocalName, lifecycleLocalName, lifecycleName),
createProjectGroup(spaceLocalName, projectGroupLocalName, projectGroupName),
createProject(spaceLocalName, projectLocalName, projectName, lifecycleLocalName, projectGroupLocalName),
localName, freezeName, start, end, projectScopes)
}

func testDeploymentFreezeExists(prefix string) resource.TestCheckFunc {
return func(s *terraform.State) error {
Expand Down

0 comments on commit 8ef300d

Please sign in to comment.