diff --git a/.github/workflows/integration-tests.yaml b/.github/workflows/integration-tests.yaml index 40a10b6e1..8f6d86960 100644 --- a/.github/workflows/integration-tests.yaml +++ b/.github/workflows/integration-tests.yaml @@ -14,8 +14,8 @@ jobs: strategy: fail-fast: false matrix: - parallel: [ 15 ] - index: [ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14 ] + parallel: [ 3 ] + index: [ 0, 1, 2 ] steps: - uses: actions/checkout@v3 @@ -84,7 +84,7 @@ jobs: - name: Test run: | GOBIN=$PWD/bin go install gotest.tools/gotestsum@latest - ./bin/gotestsum --junitfile node-summary.xml --format standard-verbose -- -run "${{ steps.test_split.outputs.run }}" -timeout 0 ./... -createSharedContainer=true + ./bin/gotestsum --junitfile node-summary.xml --format short-verbose -- -run "${{ steps.test_split.outputs.run }}" -timeout 0 ./... shell: bash env: LICENSE: ${{ secrets.OCTOPUS_SERVER_BASE64_LICENSE }} @@ -97,6 +97,7 @@ jobs: OCTOTESTVERSION: latest OCTOTESTIMAGEURL: docker.packages.octopushq.com/octopusdeploy/octopusdeploy OCTOTESTRETRYCOUNT: 1 + TF_ACC: 1 - name: Upload test artifacts if: always() uses: actions/upload-artifact@v3 @@ -128,18 +129,6 @@ jobs: "junit-test-summary-0/*.xml" "junit-test-summary-1/*.xml" "junit-test-summary-2/*.xml" - "junit-test-summary-3/*.xml" - "junit-test-summary-4/*.xml" - "junit-test-summary-5/*.xml" - "junit-test-summary-6/*.xml" - "junit-test-summary-7/*.xml" - "junit-test-summary-8/*.xml" - "junit-test-summary-9/*.xml" - "junit-test-summary-10/*.xml" - "junit-test-summary-11/*.xml" - "junit-test-summary-12/*.xml" - "junit-test-summary-13/*.xml" - "junit-test-summary-14/*.xml" - name: Upload test artifacts uses: actions/upload-artifact@v3 diff --git a/go.mod b/go.mod index 2cad3a7e8..518e49042 100644 --- a/go.mod +++ b/go.mod @@ -4,7 +4,7 @@ go 1.21 require ( github.com/OctopusDeploy/go-octopusdeploy/v2 v2.49.1 - github.com/OctopusSolutionsEngineering/OctopusTerraformTestFramework v0.0.0-20240725054341-2848f54d101e + github.com/OctopusSolutionsEngineering/OctopusTerraformTestFramework v0.0.0-20240729041805-46db6fb717b4 github.com/google/uuid v1.6.0 github.com/hashicorp/go-cty v1.4.1-0.20200723130312-85980079f637 github.com/hashicorp/terraform-plugin-docs v0.13.0 diff --git a/go.sum b/go.sum index fd5a915a5..148561b9d 100644 --- a/go.sum +++ b/go.sum @@ -24,6 +24,8 @@ github.com/OctopusDeploy/go-octopusdeploy/v2 v2.49.1 h1:lzC3tcnfvC07Ilqn5J51qhOn github.com/OctopusDeploy/go-octopusdeploy/v2 v2.49.1/go.mod h1:ggvOXzMnq+w0pLg6C9zdjz6YBaHfO3B3tqmmB7JQdaw= github.com/OctopusSolutionsEngineering/OctopusTerraformTestFramework v0.0.0-20240725054341-2848f54d101e h1:FIvWa8wNg8IBG5uVhqkKvcBhaxx4TgN7T8/5Ed4VQUE= github.com/OctopusSolutionsEngineering/OctopusTerraformTestFramework v0.0.0-20240725054341-2848f54d101e/go.mod h1:Oq9KbiRNDBB5jFmrwnrgLX0urIqR/1ptY18TzkqXm7M= +github.com/OctopusSolutionsEngineering/OctopusTerraformTestFramework v0.0.0-20240729041805-46db6fb717b4 h1:QfbVf0bOIRMp/WHAWsuVDB7KHoWnRsGbvDuOf2ua7k4= +github.com/OctopusSolutionsEngineering/OctopusTerraformTestFramework v0.0.0-20240729041805-46db6fb717b4/go.mod h1:Oq9KbiRNDBB5jFmrwnrgLX0urIqR/1ptY18TzkqXm7M= github.com/ProtonMail/go-crypto v1.1.0-alpha.2 h1:bkyFVUP+ROOARdgCiJzNQo2V2kiB97LyUpzH9P6Hrlg= github.com/ProtonMail/go-crypto v1.1.0-alpha.2/go.mod h1:rA3QumHc/FZ8pAHreoekgiAbzpNsfQAosU5td4SnOrE= github.com/agext/levenshtein v1.2.3 h1:YB2fHEn0UJagG8T1rrWknE3ZQzWM06O8AMAatNn7lmo= diff --git a/octopusdeploy/data_source_accounts_test.go b/octopusdeploy/data_source_accounts_test.go index 64268b49f..f526d02eb 100644 --- a/octopusdeploy/data_source_accounts_test.go +++ b/octopusdeploy/data_source_accounts_test.go @@ -2,20 +2,18 @@ package octopusdeploy import ( "fmt" - "testing" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/acctest" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" ) -func TestAccDataSourceAccounts(t *testing.T) { +func (suite *IntegrationTestSuite) TestAccDataSourceAccounts() { localName := acctest.RandStringFromCharSet(20, acctest.CharSetAlpha) name := fmt.Sprintf("data.octopusdeploy_accounts.%s", localName) take := 10 - resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, + resource.Test(suite.T(), resource.TestCase{ + PreCheck: func() { testAccPreCheck(suite.T()) }, ProtoV6ProviderFactories: ProtoV6ProviderFactories(), Steps: []resource.TestStep{ { diff --git a/octopusdeploy/data_source_channels_test.go b/octopusdeploy/data_source_channels_test.go index be0c46c77..322e327ad 100644 --- a/octopusdeploy/data_source_channels_test.go +++ b/octopusdeploy/data_source_channels_test.go @@ -2,20 +2,18 @@ package octopusdeploy import ( "fmt" - "testing" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/acctest" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" ) -func TestAccDataSourceChannels(t *testing.T) { +func (suite *IntegrationTestSuite) TestAccDataSourceChannels() { localName := acctest.RandStringFromCharSet(20, acctest.CharSetAlpha) name := fmt.Sprintf("data.octopusdeploy_channels.%s", localName) take := 10 - resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, + resource.Test(suite.T(), resource.TestCase{ + PreCheck: func() { testAccPreCheck(suite.T()) }, ProtoV6ProviderFactories: ProtoV6ProviderFactories(), Steps: []resource.TestStep{ { diff --git a/octopusdeploy/data_source_projects_test.go b/octopusdeploy/data_source_projects_test.go index 5426be29f..de909f0ac 100644 --- a/octopusdeploy/data_source_projects_test.go +++ b/octopusdeploy/data_source_projects_test.go @@ -2,20 +2,18 @@ package octopusdeploy import ( "fmt" - "testing" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/acctest" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" ) -func TestAccDataSourceProjects(t *testing.T) { +func (suite *IntegrationTestSuite) TestAccDataSourceProjects() { localName := acctest.RandStringFromCharSet(20, acctest.CharSetAlpha) name := fmt.Sprintf("data.octopusdeploy_projects.%s", localName) take := 10 - resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, + resource.Test(suite.T(), resource.TestCase{ + PreCheck: func() { testAccPreCheck(suite.T()) }, ProtoV6ProviderFactories: ProtoV6ProviderFactories(), Steps: []resource.TestStep{ { diff --git a/octopusdeploy/data_source_script_modules_test.go b/octopusdeploy/data_source_script_modules_test.go index f5fa0450e..f4f9946f1 100644 --- a/octopusdeploy/data_source_script_modules_test.go +++ b/octopusdeploy/data_source_script_modules_test.go @@ -2,20 +2,18 @@ package octopusdeploy import ( "fmt" - "testing" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/acctest" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" ) -func TestAccDataSourceScriptModules(t *testing.T) { +func (suite *IntegrationTestSuite) TestAccDataSourceScriptModules() { localName := acctest.RandStringFromCharSet(20, acctest.CharSetAlpha) name := fmt.Sprintf("data.octopusdeploy_script_modules.%s", localName) take := 10 - resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, + resource.Test(suite.T(), resource.TestCase{ + PreCheck: func() { testAccPreCheck(suite.T()) }, ProtoV6ProviderFactories: ProtoV6ProviderFactories(), Steps: []resource.TestStep{ { diff --git a/octopusdeploy/data_source_spaces_test.go b/octopusdeploy/data_source_spaces_test.go index 8b06cec25..ed9865b36 100644 --- a/octopusdeploy/data_source_spaces_test.go +++ b/octopusdeploy/data_source_spaces_test.go @@ -2,20 +2,18 @@ package octopusdeploy import ( "fmt" - "testing" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/acctest" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" ) -func TestAccDataSourceSpaces(t *testing.T) { +func (suite *IntegrationTestSuite) TestAccDataSourceSpaces() { localName := acctest.RandStringFromCharSet(20, acctest.CharSetAlpha) name := fmt.Sprintf("data.octopusdeploy_spaces.%s", localName) take := 10 - resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, + resource.Test(suite.T(), resource.TestCase{ + PreCheck: func() { testAccPreCheck(suite.T()) }, ProtoV6ProviderFactories: ProtoV6ProviderFactories(), Steps: []resource.TestStep{ { diff --git a/octopusdeploy/data_source_tag_sets_test.go b/octopusdeploy/data_source_tag_sets_test.go index 2fb8c668e..d20ac9989 100644 --- a/octopusdeploy/data_source_tag_sets_test.go +++ b/octopusdeploy/data_source_tag_sets_test.go @@ -2,20 +2,18 @@ package octopusdeploy import ( "fmt" - "testing" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/acctest" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" ) -func TestAccDataSourceTagSets(t *testing.T) { +func (suite *IntegrationTestSuite) TestAccDataSourceTagSets() { localName := acctest.RandStringFromCharSet(20, acctest.CharSetAlpha) name := fmt.Sprintf("data.octopusdeploy_tag_sets.%s", localName) take := 10 - resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, + resource.Test(suite.T(), resource.TestCase{ + PreCheck: func() { testAccPreCheck(suite.T()) }, ProtoV6ProviderFactories: ProtoV6ProviderFactories(), Steps: []resource.TestStep{ { diff --git a/octopusdeploy/data_source_tenants_test.go b/octopusdeploy/data_source_tenants_test.go index b7baa57c8..48ca96561 100644 --- a/octopusdeploy/data_source_tenants_test.go +++ b/octopusdeploy/data_source_tenants_test.go @@ -2,22 +2,20 @@ package octopusdeploy import ( "fmt" - "strconv" - "testing" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/acctest" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" + "strconv" ) -func TestAccDataSourceTenants(t *testing.T) { +func (suite *IntegrationTestSuite) TestAccDataSourceTenants() { localName := acctest.RandStringFromCharSet(20, acctest.CharSetAlpha) name := fmt.Sprintf("data.octopusdeploy_tenants.%s", localName) skip := acctest.RandIntRange(0, 100) take := acctest.RandIntRange(0, 100) - resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, + resource.Test(suite.T(), resource.TestCase{ + PreCheck: func() { testAccPreCheck(suite.T()) }, ProtoV6ProviderFactories: ProtoV6ProviderFactories(), Steps: []resource.TestStep{ { diff --git a/octopusdeploy/data_source_users_test.go b/octopusdeploy/data_source_users_test.go index e022c30ce..cdf19378d 100644 --- a/octopusdeploy/data_source_users_test.go +++ b/octopusdeploy/data_source_users_test.go @@ -2,20 +2,18 @@ package octopusdeploy import ( "fmt" - "testing" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/acctest" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" ) -func TestAccDataSourceUsers(t *testing.T) { +func (suite *IntegrationTestSuite) TestAccDataSourceUsers() { localName := acctest.RandStringFromCharSet(20, acctest.CharSetAlpha) name := fmt.Sprintf("data.octopusdeploy_users.%s", localName) username := "d" - resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, + resource.Test(suite.T(), resource.TestCase{ + PreCheck: func() { testAccPreCheck(suite.T()) }, ProtoV6ProviderFactories: ProtoV6ProviderFactories(), Steps: []resource.TestStep{ { diff --git a/octopusdeploy/data_source_worker_pools_test.go b/octopusdeploy/data_source_worker_pools_test.go index ba1601f8b..a7ab50695 100644 --- a/octopusdeploy/data_source_worker_pools_test.go +++ b/octopusdeploy/data_source_worker_pools_test.go @@ -2,20 +2,18 @@ package octopusdeploy import ( "fmt" - "testing" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/acctest" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" ) -func TestAccDataSourceWorkerPools(t *testing.T) { +func (suite *IntegrationTestSuite) TestAccDataSourceWorkerPools() { localName := acctest.RandStringFromCharSet(20, acctest.CharSetAlpha) name := fmt.Sprintf("data.octopusdeploy_worker_pools.%s", localName) partialName := "W" - resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, + resource.Test(suite.T(), resource.TestCase{ + PreCheck: func() { testAccPreCheck(suite.T()) }, ProtoV6ProviderFactories: ProtoV6ProviderFactories(), Steps: []resource.TestStep{ { diff --git a/octopusdeploy/resource_aws_account_integration_test.go b/octopusdeploy/resource_aws_account_integration_test.go index 6c9452c11..0eb3d9d04 100644 --- a/octopusdeploy/resource_aws_account_integration_test.go +++ b/octopusdeploy/resource_aws_account_integration_test.go @@ -5,13 +5,13 @@ import ( "github.com/OctopusSolutionsEngineering/OctopusTerraformTestFramework/octoclient" "github.com/OctopusSolutionsEngineering/OctopusTerraformTestFramework/test" "path/filepath" - "testing" ) // TestAwsAccountExport verifies that an AWS account can be reimported with the correct settings -func TestAwsAccountExport(t *testing.T) { +func (suite *IntegrationTestSuite) TestAwsAccountExport() { testFramework := test.OctopusContainerTest{} + t := suite.T() newSpaceId, err := testFramework.Act(t, octoContainer, "../terraform", "3-awsaccount", []string{}) if err != nil { diff --git a/octopusdeploy/resource_aws_account_test.go b/octopusdeploy/resource_aws_account_test.go index 848a04373..bc54c118a 100644 --- a/octopusdeploy/resource_aws_account_test.go +++ b/octopusdeploy/resource_aws_account_test.go @@ -2,14 +2,12 @@ package octopusdeploy import ( "fmt" - "testing" - "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/core" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/acctest" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" ) -func TestAccAWSAccountBasic(t *testing.T) { +func (suite *IntegrationTestSuite) TestAccAWSAccountBasic() { localName := acctest.RandStringFromCharSet(20, acctest.CharSetAlpha) prefix := "octopusdeploy_aws_account." + localName @@ -21,9 +19,9 @@ func TestAccAWSAccountBasic(t *testing.T) { newAccessKey := acctest.RandString(acctest.RandIntRange(20, 3000)) - resource.Test(t, resource.TestCase{ - CheckDestroy: testAccountCheckDestroy, - PreCheck: func() { testAccPreCheck(t) }, + resource.Test(suite.T(), resource.TestCase{ + CheckDestroy: testAccountCheckDestroy, + PreCheck: func() { testAccPreCheck(suite.T()) }, ProtoV6ProviderFactories: ProtoV6ProviderFactories(), Steps: []resource.TestStep{ { diff --git a/octopusdeploy/resource_aws_openid_connect_account_test.go b/octopusdeploy/resource_aws_openid_connect_account_test.go index e2af3007e..eead69503 100644 --- a/octopusdeploy/resource_aws_openid_connect_account_test.go +++ b/octopusdeploy/resource_aws_openid_connect_account_test.go @@ -2,16 +2,14 @@ package octopusdeploy import ( "fmt" - "strings" - "testing" - "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/core" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/acctest" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" + "strings" ) -func TestAccAWSOIDCAccountBasic(t *testing.T) { - SkipCI(t, "Session Duration conversion in the schema is handled incorrectly") +func (suite *IntegrationTestSuite) TestAccAWSOIDCAccountBasic() { + SkipCI(suite.T(), "Session Duration conversion in the schema is handled incorrectly") localName := acctest.RandStringFromCharSet(20, acctest.CharSetAlpha) prefix := "octopusdeploy_aws_account." + localName @@ -25,9 +23,9 @@ func TestAccAWSOIDCAccountBasic(t *testing.T) { healthKeys := []string{"target"} accountKeys := []string{"type"} - resource.Test(t, resource.TestCase{ + resource.Test(suite.T(), resource.TestCase{ CheckDestroy: testAccountCheckDestroy, - PreCheck: func() { testAccPreCheck(t) }, + PreCheck: func() { testAccPreCheck(suite.T()) }, ProtoV6ProviderFactories: ProtoV6ProviderFactories(), Steps: []resource.TestStep{ { diff --git a/octopusdeploy/resource_azure_cloud_service_deployment_target_test.go b/octopusdeploy/resource_azure_cloud_service_deployment_target_test.go index 6079ea098..cffa72b52 100644 --- a/octopusdeploy/resource_azure_cloud_service_deployment_target_test.go +++ b/octopusdeploy/resource_azure_cloud_service_deployment_target_test.go @@ -4,20 +4,20 @@ import ( "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/machines" "github.com/OctopusSolutionsEngineering/OctopusTerraformTestFramework/octoclient" "github.com/OctopusSolutionsEngineering/OctopusTerraformTestFramework/test" - "testing" ) // TestAzureCloudServiceTargetResource verifies that a azure cloud service target can be reimported with the correct settings -func TestAzureCloudServiceTargetResource(t *testing.T) { +func (suite *IntegrationTestSuite) TestAzureCloudServiceTargetResource() { // I could not figure out a combination of properties that made the octopusdeploy_azure_subscription_account resource work return + t := suite.T() testFramework := test.OctopusContainerTest{} - newSpaceId, err := testFramework.Act(t, octoContainer, "../terraform", "35-azurecloudservicetarget", []string{}) + newSpaceId, err := testFramework.Act(suite.T(), octoContainer, "../terraform", "35-azurecloudservicetarget", []string{}) if err != nil { - t.Fatal(err.Error()) + suite.T().Fatal(err.Error()) } // Assert diff --git a/octopusdeploy/resource_azure_oidc_account_test.go b/octopusdeploy/resource_azure_oidc_account_test.go index f25ad98d7..02afecbb4 100644 --- a/octopusdeploy/resource_azure_oidc_account_test.go +++ b/octopusdeploy/resource_azure_oidc_account_test.go @@ -2,16 +2,14 @@ package octopusdeploy import ( "fmt" - "testing" - "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/core" uuid "github.com/google/uuid" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/acctest" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" ) -func TestAccOctopusDeployAzureOpenIDConnectAccountBasic(t *testing.T) { - SkipCI(t, "audience is not set on initial creation") +func (suite *IntegrationTestSuite) TestAccOctopusDeployAzureOpenIDConnectAccountBasic() { + SkipCI(suite.T(), "audience is not set on initial creation") localName := acctest.RandStringFromCharSet(20, acctest.CharSetAlpha) prefix := "octopusdeploy_azure_openid_connect." + localName @@ -29,9 +27,9 @@ func TestAccOctopusDeployAzureOpenIDConnectAccountBasic(t *testing.T) { newDescription := acctest.RandStringFromCharSet(20, acctest.CharSetAlpha) - resource.Test(t, resource.TestCase{ + resource.Test(suite.T(), resource.TestCase{ CheckDestroy: testAccountCheckDestroy, - PreCheck: func() { testAccPreCheck(t) }, + PreCheck: func() { testAccPreCheck(suite.T()) }, ProtoV6ProviderFactories: ProtoV6ProviderFactories(), Steps: []resource.TestStep{ { diff --git a/octopusdeploy/resource_azure_service_fabric_cluster_deployment_target_test.go b/octopusdeploy/resource_azure_service_fabric_cluster_deployment_target_test.go index ba75e9737..2a0a3e295 100644 --- a/octopusdeploy/resource_azure_service_fabric_cluster_deployment_target_test.go +++ b/octopusdeploy/resource_azure_service_fabric_cluster_deployment_target_test.go @@ -5,12 +5,12 @@ import ( "github.com/OctopusSolutionsEngineering/OctopusTerraformTestFramework/octoclient" "github.com/OctopusSolutionsEngineering/OctopusTerraformTestFramework/test" "path/filepath" - "testing" ) // TestAzureServiceFabricTargetResource verifies that a service fabric target can be reimported with the correct settings -func TestAzureServiceFabricTargetResource(t *testing.T) { +func (suite *IntegrationTestSuite) TestAzureServiceFabricTargetResource() { testFramework := test.OctopusContainerTest{} + t := suite.T() newSpaceId, err := testFramework.Act(t, octoContainer, "../terraform", "36-servicefabrictarget", []string{ "-var=target_service_fabric=whatever", diff --git a/octopusdeploy/resource_azure_service_principal_account_integration_test.go b/octopusdeploy/resource_azure_service_principal_account_integration_test.go index 7c13e1dc2..4b79ac953 100644 --- a/octopusdeploy/resource_azure_service_principal_account_integration_test.go +++ b/octopusdeploy/resource_azure_service_principal_account_integration_test.go @@ -5,12 +5,12 @@ import ( "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/accounts" "github.com/OctopusSolutionsEngineering/OctopusTerraformTestFramework/octoclient" "github.com/OctopusSolutionsEngineering/OctopusTerraformTestFramework/test" - "testing" ) // TestAzureAccountResource verifies that an Azure account can be reimported with the correct settings -func TestAzureAccountResource(t *testing.T) { +func (suite *IntegrationTestSuite) TestAzureAccountResource() { testFramework := test.OctopusContainerTest{} + t := suite.T() newSpaceId, err := testFramework.Act(t, octoContainer, "../terraform", "4-azureaccount", []string{}) diff --git a/octopusdeploy/resource_azure_service_principal_account_test.go b/octopusdeploy/resource_azure_service_principal_account_test.go index dab42e1c9..60a518754 100644 --- a/octopusdeploy/resource_azure_service_principal_account_test.go +++ b/octopusdeploy/resource_azure_service_principal_account_test.go @@ -2,15 +2,13 @@ package octopusdeploy import ( "fmt" - "testing" - "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/core" uuid "github.com/google/uuid" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/acctest" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" ) -func TestAccOctopusDeployAzureServicePrincipalAccountBasic(t *testing.T) { +func (suite *IntegrationTestSuite) TestAccOctopusDeployAzureServicePrincipalAccountBasic() { localName := acctest.RandStringFromCharSet(20, acctest.CharSetAlpha) prefix := "octopusdeploy_azure_service_principal." + localName @@ -24,9 +22,9 @@ func TestAccOctopusDeployAzureServicePrincipalAccountBasic(t *testing.T) { newDescription := acctest.RandStringFromCharSet(20, acctest.CharSetAlpha) - resource.Test(t, resource.TestCase{ - CheckDestroy: testAccountCheckDestroy, - PreCheck: func() { testAccPreCheck(t) }, + resource.Test(suite.T(), resource.TestCase{ + CheckDestroy: testAccountCheckDestroy, + PreCheck: func() { testAccPreCheck(suite.T()) }, ProtoV6ProviderFactories: ProtoV6ProviderFactories(), Steps: []resource.TestStep{ { diff --git a/octopusdeploy/resource_azure_subscription_account_test.go b/octopusdeploy/resource_azure_subscription_account_test.go index 1baa68ee6..8af227839 100644 --- a/octopusdeploy/resource_azure_subscription_account_test.go +++ b/octopusdeploy/resource_azure_subscription_account_test.go @@ -3,17 +3,15 @@ package octopusdeploy import ( "fmt" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/accounts" + "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/core" "github.com/OctopusSolutionsEngineering/OctopusTerraformTestFramework/octoclient" "github.com/OctopusSolutionsEngineering/OctopusTerraformTestFramework/test" - "testing" - - "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/core" uuid "github.com/google/uuid" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/acctest" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" ) -func TestAccOctopusDeployAzureSubscriptionAccountBasic(t *testing.T) { +func (suite *IntegrationTestSuite) TestAccOctopusDeployAzureSubscriptionAccountBasic() { localName := acctest.RandStringFromCharSet(20, acctest.CharSetAlpha) resourceName := "octopusdeploy_azure_subscription_account." + localName @@ -27,9 +25,9 @@ func TestAccOctopusDeployAzureSubscriptionAccountBasic(t *testing.T) { newDescription := acctest.RandStringFromCharSet(20, acctest.CharSetAlpha) - resource.Test(t, resource.TestCase{ + resource.Test(suite.T(), resource.TestCase{ CheckDestroy: testAccountCheckDestroy, - PreCheck: func() { testAccPreCheck(t) }, + PreCheck: func() { testAccPreCheck(suite.T()) }, ProtoV6ProviderFactories: ProtoV6ProviderFactories(), Steps: []resource.TestStep{ { @@ -75,8 +73,9 @@ func testAzureSubscriptionAccountBasic(localName string, azureEnvironment string } // TestAzureSubscriptionAccountResource verifies that an azure account can be reimported with the correct settings -func TestAzureSubscriptionAccountResource(t *testing.T) { +func (suite *IntegrationTestSuite) TestAzureSubscriptionAccountResource() { testFramework := test.OctopusContainerTest{} + t := suite.T() newSpaceId, err := testFramework.Act(t, octoContainer, "../terraform", "8-azuresubscriptionaccount", []string{}) diff --git a/octopusdeploy/resource_azure_web_app_deployment_target_test.go b/octopusdeploy/resource_azure_web_app_deployment_target_test.go index 663ea4d31..c1f941e50 100644 --- a/octopusdeploy/resource_azure_web_app_deployment_target_test.go +++ b/octopusdeploy/resource_azure_web_app_deployment_target_test.go @@ -2,28 +2,26 @@ package octopusdeploy import ( "fmt" + "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/core" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/machines" "github.com/OctopusSolutionsEngineering/OctopusTerraformTestFramework/octoclient" "github.com/OctopusSolutionsEngineering/OctopusTerraformTestFramework/test" - "path/filepath" - "testing" - - "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/core" "github.com/google/uuid" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/acctest" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" + "path/filepath" ) -func TestAccOctopusDeployAzureWebAppDeploymentTargetBasic(t *testing.T) { +func (suite *IntegrationTestSuite) TestAccOctopusDeployAzureWebAppDeploymentTargetBasic() { localName := acctest.RandStringFromCharSet(20, acctest.CharSetAlpha) name := acctest.RandStringFromCharSet(20, acctest.CharSetAlpha) resourceName := "octopusdeploy_azure_web_app_deployment_target." + localName tenantedDeploymentMode := core.TenantedDeploymentModeTenantedOrUntenanted webAppName := acctest.RandStringFromCharSet(20, acctest.CharSetAlpha) - resource.Test(t, resource.TestCase{ + resource.Test(suite.T(), resource.TestCase{ CheckDestroy: testAccountCheckDestroy, - PreCheck: func() { testAccPreCheck(t) }, + PreCheck: func() { testAccPreCheck(suite.T()) }, ProtoV6ProviderFactories: ProtoV6ProviderFactories(), Steps: []resource.TestStep{ { @@ -70,8 +68,9 @@ func testAzureWebAppDeploymentTargetBasic(localName string, name string, tenante } // TestAzureWebAppTargetResource verifies that a web app target can be reimported with the correct settings -func TestAzureWebAppTargetResource(t *testing.T) { +func (suite *IntegrationTestSuite) TestAzureWebAppTargetResource() { testFramework := test.OctopusContainerTest{} + t := suite.T() newSpaceId, err := testFramework.Act(t, octoContainer, "../terraform", "37-webapptarget", []string{ "-var=account_sales_account=whatever", diff --git a/octopusdeploy/resource_certificate_test.go b/octopusdeploy/resource_certificate_test.go index eb2c49638..8d93c41c1 100644 --- a/octopusdeploy/resource_certificate_test.go +++ b/octopusdeploy/resource_certificate_test.go @@ -5,15 +5,13 @@ import ( "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/certificates" "github.com/OctopusSolutionsEngineering/OctopusTerraformTestFramework/octoclient" "github.com/OctopusSolutionsEngineering/OctopusTerraformTestFramework/test" - "path/filepath" - "testing" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/acctest" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" + "path/filepath" ) -func TestAccOctopusDeployCertificateBasic(t *testing.T) { +func (suite *IntegrationTestSuite) TestAccOctopusDeployCertificateBasic() { localName := acctest.RandStringFromCharSet(20, acctest.CharSetAlpha) prefix := "octopusdeploy_certificate." + localName @@ -21,9 +19,9 @@ func TestAccOctopusDeployCertificateBasic(t *testing.T) { name := acctest.RandStringFromCharSet(20, acctest.CharSetAlpha) password := acctest.RandStringFromCharSet(20, acctest.CharSetAlpha) - resource.Test(t, resource.TestCase{ + resource.Test(suite.T(), resource.TestCase{ CheckDestroy: testAccCertificateCheckDestroy, - PreCheck: func() { testAccPreCheck(t) }, + PreCheck: func() { testAccPreCheck(suite.T()) }, ProtoV6ProviderFactories: ProtoV6ProviderFactories(), Steps: []resource.TestStep{ { @@ -74,8 +72,9 @@ func testAccCertificateCheckDestroy(s *terraform.State) error { } // TestCertificateResource verifies that a certificate can be reimported with the correct settings -func TestCertificateResource(t *testing.T) { +func (suite *IntegrationTestSuite) TestCertificateResource() { testFramework := test.OctopusContainerTest{} + t := suite.T() newSpaceId, err := testFramework.Act(t, octoContainer, "../terraform", "25-certificates", []string{}) diff --git a/octopusdeploy/resource_channel_test.go b/octopusdeploy/resource_channel_test.go index 4006aa390..fbb812ce2 100644 --- a/octopusdeploy/resource_channel_test.go +++ b/octopusdeploy/resource_channel_test.go @@ -3,20 +3,18 @@ package octopusdeploy import ( "fmt" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/channels" - "github.com/OctopusSolutionsEngineering/OctopusTerraformTestFramework/octoclient" - "github.com/OctopusSolutionsEngineering/OctopusTerraformTestFramework/test" - "net/http" - "path/filepath" - "testing" - "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/client" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/core" + "github.com/OctopusSolutionsEngineering/OctopusTerraformTestFramework/octoclient" + "github.com/OctopusSolutionsEngineering/OctopusTerraformTestFramework/test" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/acctest" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" + "net/http" + "path/filepath" ) -func TestAccOctopusDeployChannelBasic(t *testing.T) { +func (suite *IntegrationTestSuite) TestAccOctopusDeployChannelBasic() { lifecycleLocalName := acctest.RandStringFromCharSet(20, acctest.CharSetAlpha) lifecycleName := acctest.RandStringFromCharSet(20, acctest.CharSetAlpha) localName := acctest.RandStringFromCharSet(20, acctest.CharSetAlpha) @@ -29,6 +27,7 @@ func TestAccOctopusDeployChannelBasic(t *testing.T) { resourceName := "octopusdeploy_channel." + localName name := acctest.RandStringFromCharSet(20, acctest.CharSetAlpha) description := acctest.RandStringFromCharSet(20, acctest.CharSetAlpha) + t := suite.T() resource.Test(t, resource.TestCase{ CheckDestroy: testAccChannelCheckDestroy, @@ -48,7 +47,7 @@ func TestAccOctopusDeployChannelBasic(t *testing.T) { }) } -func TestAccOctopusDeployChannelBasicWithUpdate(t *testing.T) { +func (suite *IntegrationTestSuite) TestAccOctopusDeployChannelBasicWithUpdate() { lifecycleLocalName := acctest.RandStringFromCharSet(20, acctest.CharSetAlpha) lifecycleName := acctest.RandStringFromCharSet(20, acctest.CharSetAlpha) localName := acctest.RandStringFromCharSet(20, acctest.CharSetAlpha) @@ -60,6 +59,7 @@ func TestAccOctopusDeployChannelBasicWithUpdate(t *testing.T) { resourceName := "octopusdeploy_channel." + localName const channelName = "Funky Channel" + t := suite.T() resource.Test(t, resource.TestCase{ CheckDestroy: testAccChannelCheckDestroy, @@ -88,7 +88,8 @@ func TestAccOctopusDeployChannelBasicWithUpdate(t *testing.T) { }) } -func TestAccOctopusDeployChannelWithOneRule(t *testing.T) { +func (suite *IntegrationTestSuite) TestAccOctopusDeployChannelWithOneRule() { + t := suite.T() SkipCI(t, "action_package blocks required on rule, this test is out of date.") const terraformNamePrefix = "octopusdeploy_channel.ch" const channelName = "Funky Channel" @@ -115,7 +116,8 @@ func TestAccOctopusDeployChannelWithOneRule(t *testing.T) { }) } -func TestAccOctopusDeployChannelWithOneRuleWithUpdate(t *testing.T) { +func (suite *IntegrationTestSuite) TestAccOctopusDeployChannelWithOneRuleWithUpdate() { + t := suite.T() SkipCI(t, "action_package blocks required on rule, this test is out of date.") const terraformNamePrefix = "octopusdeploy_channel.ch" const channelName = "Funky Channel" @@ -156,7 +158,8 @@ func TestAccOctopusDeployChannelWithOneRuleWithUpdate(t *testing.T) { }) } -func TestAccOctopusDeployChannelWithTwoRules(t *testing.T) { +func (suite *IntegrationTestSuite) TestAccOctopusDeployChannelWithTwoRules() { + t := suite.T() SkipCI(t, "action_package blocks required on rule, this test is out of date.") const terraformNamePrefix = "octopusdeploy_channel.ch" const channelName = "Funky Channel" @@ -365,7 +368,8 @@ func destroyHelperChannel(s *terraform.State, client *client.Client) error { } // TestProjectChannelResource verifies that a project channel can be reimported with the correct settings -func TestProjectChannelResource(t *testing.T) { +func (suite *IntegrationTestSuite) TestProjectChannelResource() { + t := suite.T() testFramework := test.OctopusContainerTest{} newSpaceId, err := testFramework.Act(t, octoContainer, "../terraform", "20-channel", []string{}) diff --git a/octopusdeploy/resource_cloud_region_deployment_target_test.go b/octopusdeploy/resource_cloud_region_deployment_target_test.go index cb5c01ca0..35b203ca7 100644 --- a/octopusdeploy/resource_cloud_region_deployment_target_test.go +++ b/octopusdeploy/resource_cloud_region_deployment_target_test.go @@ -5,17 +5,16 @@ import ( "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/machines" "github.com/OctopusSolutionsEngineering/OctopusTerraformTestFramework/octoclient" "github.com/OctopusSolutionsEngineering/OctopusTerraformTestFramework/test" - "path/filepath" - "testing" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/acctest" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" + "path/filepath" ) -func TestAccCloudRegionDeploymentTargetImportBasic(t *testing.T) { +func (suite *IntegrationTestSuite) TestAccCloudRegionDeploymentTargetImportBasic() { localName := acctest.RandStringFromCharSet(20, acctest.CharSetAlpha) resourceName := "octopusdeploy_cloud_region_deployment_target." + localName + t := suite.T() name := acctest.RandStringFromCharSet(16, acctest.CharSetAlpha) @@ -36,15 +35,15 @@ func TestAccCloudRegionDeploymentTargetImportBasic(t *testing.T) { }) } -func TestAccCloudRegionDeploymentTargetBasic(t *testing.T) { +func (suite *IntegrationTestSuite) TestAccCloudRegionDeploymentTargetBasic() { localName := acctest.RandStringFromCharSet(20, acctest.CharSetAlpha) resourceName := "octopusdeploy_cloud_region_deployment_target." + localName name := acctest.RandStringFromCharSet(16, acctest.CharSetAlpha) - resource.Test(t, resource.TestCase{ + resource.Test(suite.T(), resource.TestCase{ CheckDestroy: testAccCloudRegionDeploymentTargetCheckDestroy, - PreCheck: func() { testAccPreCheck(t) }, + PreCheck: func() { testAccPreCheck(suite.T()) }, ProtoV6ProviderFactories: ProtoV6ProviderFactories(), Steps: []resource.TestStep{ { @@ -102,8 +101,9 @@ func testAccCloudRegionDeploymentTargetCheckDestroy(s *terraform.State) error { } // TestCloudRegionTargetResource verifies that a cloud region can be reimported with the correct settings -func TestCloudRegionTargetResource(t *testing.T) { +func (suite *IntegrationTestSuite) TestCloudRegionTargetResource() { testFramework := test.OctopusContainerTest{} + t := suite.T() newSpaceId, err := testFramework.Act(t, octoContainer, "../terraform", "33-cloudregiontarget", []string{}) diff --git a/octopusdeploy/resource_deployment_process_test.go b/octopusdeploy/resource_deployment_process_test.go index 12f744d32..02bb81730 100644 --- a/octopusdeploy/resource_deployment_process_test.go +++ b/octopusdeploy/resource_deployment_process_test.go @@ -2,18 +2,16 @@ package octopusdeploy import ( "fmt" + "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/client" + "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/deployments" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/projects" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/workerpools" "github.com/OctopusSolutionsEngineering/OctopusTerraformTestFramework/octoclient" "github.com/OctopusSolutionsEngineering/OctopusTerraformTestFramework/test" - "strings" - "testing" - - "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/client" - "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/deployments" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/acctest" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" + "strings" ) // func TestAccDeploymentProcess(t *testing.T) { @@ -63,9 +61,10 @@ import ( // }`, options.LocalName, options.Project.LocalName, options.StepName, options.ActionType, options.ActionName, options.PackageName, options.PackageID) // } -func TestAccOctopusDeployDeploymentProcessBasic(t *testing.T) { +func (suite *IntegrationTestSuite) TestAccOctopusDeployDeploymentProcessBasic() { localName := acctest.RandStringFromCharSet(20, acctest.CharSetAlpha) resourceName := "octopusdeploy_deployment_process." + localName + t := suite.T() resource.Test(t, resource.TestCase{ CheckDestroy: resource.ComposeTestCheckFunc( @@ -89,7 +88,8 @@ func TestAccOctopusDeployDeploymentProcessBasic(t *testing.T) { }) } -func TestAccOctopusDeployDeploymentProcessWithActionTemplate(t *testing.T) { +func (suite *IntegrationTestSuite) TestAccOctopusDeployDeploymentProcessWithActionTemplate() { + t := suite.T() SkipCI(t, "Unsupported block type on `template` block") localName := acctest.RandStringFromCharSet(20, acctest.CharSetAlpha) resourceName := "octopusdeploy_deployment_process." + localName @@ -129,9 +129,10 @@ func TestAccOctopusDeployDeploymentProcessWithActionTemplate(t *testing.T) { }) } -func TestAccOctopusDeployDeploymentProcessWithImpliedPrimaryPackage(t *testing.T) { +func (suite *IntegrationTestSuite) TestAccOctopusDeployDeploymentProcessWithImpliedPrimaryPackage() { localName := acctest.RandStringFromCharSet(20, acctest.CharSetAlpha) resourceName := "octopusdeploy_deployment_process." + localName + t := suite.T() spaceID := acctest.RandStringFromCharSet(20, acctest.CharSetAlpha) @@ -418,8 +419,9 @@ func testAccDeploymentProcessCheckDestroy(s *terraform.State) error { return nil } -func TestDeploymentProcessWithGitDependency(t *testing.T) { +func (suite *IntegrationTestSuite) TestDeploymentProcessWithGitDependency() { testFramework := test.OctopusContainerTest{} + t := suite.T() newSpaceId, err := testFramework.Act(t, octoContainer, "../terraform", "51-deploymentprocesswithgitdependency", []string{}) @@ -469,8 +471,9 @@ func TestDeploymentProcessWithGitDependency(t *testing.T) { // TestTerraformApplyStepWithWorkerPool verifies that a terraform apply step with a custom worker pool is deployed successfully // See https://github.com/OctopusDeployLabs/terraform-provider-octopusdeploy/issues/601 -func TestTerraformApplyStepWithWorkerPool(t *testing.T) { +func (suite *IntegrationTestSuite) TestTerraformApplyStepWithWorkerPool() { testFramework := test.OctopusContainerTest{} + t := suite.T() newSpaceId, err := testFramework.Act(t, octoContainer, "../terraform", "50-applyterraformtemplateaction", []string{}) diff --git a/octopusdeploy/resource_docker_container_registry_test.go b/octopusdeploy/resource_docker_container_registry_test.go index 377ced443..c47aba307 100644 --- a/octopusdeploy/resource_docker_container_registry_test.go +++ b/octopusdeploy/resource_docker_container_registry_test.go @@ -5,17 +5,16 @@ import ( "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/feeds" "github.com/OctopusSolutionsEngineering/OctopusTerraformTestFramework/octoclient" "github.com/OctopusSolutionsEngineering/OctopusTerraformTestFramework/test" - "path/filepath" - "testing" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/acctest" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" + "path/filepath" ) -func TestAccOctopusDeployDockerContainerRegistry(t *testing.T) { +func (suite *IntegrationTestSuite) TestAccOctopusDeployDockerContainerRegistry() { localName := acctest.RandStringFromCharSet(20, acctest.CharSetAlpha) prefix := "octopusdeploy_docker_container_registry." + localName + t := suite.T() apiVersion := acctest.RandStringFromCharSet(20, acctest.CharSetAlpha) feedURI := "https://index.docker.io" @@ -83,8 +82,9 @@ func testDockerContainerRegistryCheckDestroy(s *terraform.State) error { } // TestDockerFeedResource verifies that a docker feed can be reimported with the correct settings -func TestDockerFeedResource(t *testing.T) { +func (suite *IntegrationTestSuite) TestDockerFeedResource() { testFramework := test.OctopusContainerTest{} + t := suite.T() newSpaceId, err := testFramework.Act(t, octoContainer, "../terraform", "11-dockerfeed", []string{}) diff --git a/octopusdeploy/resource_dynamic_worker_pool_test.go b/octopusdeploy/resource_dynamic_worker_pool_test.go index 09333a338..e97231e9f 100644 --- a/octopusdeploy/resource_dynamic_worker_pool_test.go +++ b/octopusdeploy/resource_dynamic_worker_pool_test.go @@ -2,15 +2,14 @@ package octopusdeploy import ( "fmt" - "strconv" - "testing" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/acctest" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" + "strconv" ) -func TestAccOctopusDeployDynamicWorkerPoolBasic(t *testing.T) { +func (suite *IntegrationTestSuite) TestAccOctopusDeployDynamicWorkerPoolBasic() { + t := suite.T() SkipCI(t, "[The worker image specified does not exist.] ") localName := acctest.RandStringFromCharSet(20, acctest.CharSetAlpha) prefix := "octopusdeploy_dynamic_worker_pool." + localName diff --git a/octopusdeploy/resource_external_feed_create_release_trigger_test.go b/octopusdeploy/resource_external_feed_create_release_trigger_test.go index ffd0aace8..7891e65c1 100644 --- a/octopusdeploy/resource_external_feed_create_release_trigger_test.go +++ b/octopusdeploy/resource_external_feed_create_release_trigger_test.go @@ -7,11 +7,11 @@ import ( "github.com/OctopusSolutionsEngineering/OctopusTerraformTestFramework/octoclient" "github.com/OctopusSolutionsEngineering/OctopusTerraformTestFramework/test" stdslices "slices" - "testing" ) -func TestPackageFeedCreateReleaseTriggerResources(t *testing.T) { +func (suite *IntegrationTestSuite) TestPackageFeedCreateReleaseTriggerResources() { testFramework := test.OctopusContainerTest{} + t := suite.T() newSpaceId, err := testFramework.Act(t, octoContainer, "../terraform", "52-packagefeedcreatereleasetrigger", []string{}) diff --git a/octopusdeploy/resource_gcp_account_integration_test.go b/octopusdeploy/resource_gcp_account_integration_test.go index c7697026f..9c71ea3bf 100644 --- a/octopusdeploy/resource_gcp_account_integration_test.go +++ b/octopusdeploy/resource_gcp_account_integration_test.go @@ -4,12 +4,12 @@ import ( "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/accounts" "github.com/OctopusSolutionsEngineering/OctopusTerraformTestFramework/octoclient" "github.com/OctopusSolutionsEngineering/OctopusTerraformTestFramework/test" - "testing" ) // TestGcpAccountResource verifies that a GCP account can be reimported with the correct settings -func TestGcpAccountResource(t *testing.T) { +func (suite *IntegrationTestSuite) TestGcpAccountResource() { testFramework := test.OctopusContainerTest{} + t := suite.T() newSpaceId, err := testFramework.Act(t, octoContainer, "../terraform", "6-gcpaccount", []string{}) diff --git a/octopusdeploy/resource_gcp_account_test.go b/octopusdeploy/resource_gcp_account_test.go index c17770d46..fa814b5b3 100644 --- a/octopusdeploy/resource_gcp_account_test.go +++ b/octopusdeploy/resource_gcp_account_test.go @@ -2,16 +2,15 @@ package octopusdeploy import ( "fmt" - "testing" - "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/core" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/acctest" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" ) -func TestAccGcpAccountBasic(t *testing.T) { +func (suite *IntegrationTestSuite) TestAccGcpAccountBasic() { localName := acctest.RandStringFromCharSet(20, acctest.CharSetAlpha) prefix := "octopusdeploy_gcp_account." + localName + t := suite.T() jsonKey := acctest.RandString(acctest.RandIntRange(20, 255)) description := acctest.RandStringFromCharSet(20, acctest.CharSetAlpha) @@ -19,8 +18,8 @@ func TestAccGcpAccountBasic(t *testing.T) { tenantedDeploymentParticipation := core.TenantedDeploymentModeTenantedOrUntenanted resource.Test(t, resource.TestCase{ - CheckDestroy: testAccountCheckDestroy, - PreCheck: func() { testAccPreCheck(t) }, + CheckDestroy: testAccountCheckDestroy, + PreCheck: func() { testAccPreCheck(t) }, ProtoV6ProviderFactories: ProtoV6ProviderFactories(), Steps: []resource.TestStep{ { diff --git a/octopusdeploy/resource_kubernetes_cluster_deployment_target_test.go b/octopusdeploy/resource_kubernetes_cluster_deployment_target_test.go index 0b92199bd..b5a968362 100644 --- a/octopusdeploy/resource_kubernetes_cluster_deployment_target_test.go +++ b/octopusdeploy/resource_kubernetes_cluster_deployment_target_test.go @@ -5,15 +5,13 @@ import ( "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/machines" "github.com/OctopusSolutionsEngineering/OctopusTerraformTestFramework/octoclient" "github.com/OctopusSolutionsEngineering/OctopusTerraformTestFramework/test" - "path/filepath" - stdslices "slices" - "testing" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/acctest" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" + "path/filepath" + stdslices "slices" ) -func TestAccKubernetesClusterDeploymentTargetBasic(t *testing.T) { +func (suite *IntegrationTestSuite) TestAccKubernetesClusterDeploymentTargetBasic() { accountLocalName := acctest.RandStringFromCharSet(20, acctest.CharSetAlpha) accountName := acctest.RandStringFromCharSet(20, acctest.CharSetAlpha) accountUsername := acctest.RandStringFromCharSet(20, acctest.CharSetAlpha) @@ -28,9 +26,9 @@ func TestAccKubernetesClusterDeploymentTargetBasic(t *testing.T) { newClusterURL := "http://www.example.com" - resource.Test(t, resource.TestCase{ + resource.Test(suite.T(), resource.TestCase{ CheckDestroy: testDeploymentTargetCheckDestroy, - PreCheck: func() { testAccPreCheck(t) }, + PreCheck: func() { testAccPreCheck(suite.T()) }, ProtoV6ProviderFactories: ProtoV6ProviderFactories(), Steps: []resource.TestStep{ { @@ -43,7 +41,7 @@ func TestAccKubernetesClusterDeploymentTargetBasic(t *testing.T) { }) } -func TestAccKubernetesClusterDeploymentTargetAws(t *testing.T) { +func (suite *IntegrationTestSuite) TestAccKubernetesClusterDeploymentTargetAws() { accountLocalName := acctest.RandStringFromCharSet(20, acctest.CharSetAlpha) accountName := acctest.RandStringFromCharSet(20, acctest.CharSetAlpha) accountAccessKey := acctest.RandStringFromCharSet(20, acctest.CharSetAlpha) @@ -58,9 +56,9 @@ func TestAccKubernetesClusterDeploymentTargetAws(t *testing.T) { localName := acctest.RandStringFromCharSet(20, acctest.CharSetAlpha) name := acctest.RandStringFromCharSet(16, acctest.CharSetAlpha) - resource.Test(t, resource.TestCase{ + resource.Test(suite.T(), resource.TestCase{ CheckDestroy: testDeploymentTargetCheckDestroy, - PreCheck: func() { testAccPreCheck(t) }, + PreCheck: func() { testAccPreCheck(suite.T()) }, ProtoV6ProviderFactories: ProtoV6ProviderFactories(), Steps: []resource.TestStep{ { @@ -82,7 +80,7 @@ func TestAccKubernetesClusterDeploymentTargetAws(t *testing.T) { }) } -func TestAccKubernetesClusterDeploymentTargetGcp(t *testing.T) { +func (suite *IntegrationTestSuite) TestAccKubernetesClusterDeploymentTargetGcp() { accountLocalName := acctest.RandStringFromCharSet(20, acctest.CharSetAlpha) accountName := acctest.RandStringFromCharSet(20, acctest.CharSetAlpha) accountUsername := acctest.RandStringFromCharSet(20, acctest.CharSetAlpha) @@ -98,9 +96,9 @@ func TestAccKubernetesClusterDeploymentTargetGcp(t *testing.T) { project := acctest.RandStringFromCharSet(16, acctest.CharSetAlpha) region := acctest.RandStringFromCharSet(16, acctest.CharSetAlpha) - resource.Test(t, resource.TestCase{ + resource.Test(suite.T(), resource.TestCase{ CheckDestroy: testDeploymentTargetCheckDestroy, - PreCheck: func() { testAccPreCheck(t) }, + PreCheck: func() { testAccPreCheck(suite.T()) }, ProtoV6ProviderFactories: ProtoV6ProviderFactories(), Steps: []resource.TestStep{ { @@ -231,8 +229,9 @@ func testAccKubernetesClusterDeploymentTargetAws( } // TestK8sTargetResource verifies that a k8s machine can be reimported with the correct settings -func TestK8sTargetResource(t *testing.T) { +func (suite *IntegrationTestSuite) TestK8sTargetResource() { testFramework := test.OctopusContainerTest{} + t := suite.T() newSpaceId, err := testFramework.Act(t, octoContainer, "../terraform", "29-k8starget", []string{}) if err != nil { @@ -280,8 +279,9 @@ func TestK8sTargetResource(t *testing.T) { } // TestK8sTargetResource verifies that a k8s machine can be reimported with the correct settings -func TestK8sTargetWithCertResource(t *testing.T) { +func (suite *IntegrationTestSuite) TestK8sTargetWithCertResource() { testFramework := test.OctopusContainerTest{} + t := suite.T() newSpaceId, err := testFramework.Act(t, octoContainer, "../terraform", "47-k8stargetwithcert", []string{}) if err != nil { @@ -316,8 +316,9 @@ func TestK8sTargetWithCertResource(t *testing.T) { } // TestK8sPodAuthTargetResource verifies that a k8s machine with pod auth can be reimported with the correct settings -func TestK8sPodAuthTargetResource(t *testing.T) { +func (suite *IntegrationTestSuite) TestK8sPodAuthTargetResource() { testFramework := test.OctopusContainerTest{} + t := suite.T() newSpaceId, err := testFramework.Act(t, octoContainer, "../terraform", "48-k8stargetpodauth", []string{}) if err != nil { @@ -359,8 +360,9 @@ func TestK8sPodAuthTargetResource(t *testing.T) { } } -func TestKubernetesDeploymentTargetData(t *testing.T) { +func (suite *IntegrationTestSuite) TestKubernetesDeploymentTargetData() { testFramework := test.OctopusContainerTest{} + t := suite.T() newSpaceId, err := testFramework.Act(t, octoContainer, "../terraform", "55-kubernetesagentdeploymenttarget", []string{}) if err != nil { @@ -395,8 +397,9 @@ func TestKubernetesDeploymentTargetData(t *testing.T) { } } -func TestKubernetesDeploymentTargetResource(t *testing.T) { +func (suite *IntegrationTestSuite) TestKubernetesDeploymentTargetResource() { testFramework := test.OctopusContainerTest{} + t := suite.T() newSpaceId, err := testFramework.Act(t, octoContainer, "../terraform", "55-kubernetesagentdeploymenttarget", []string{}) if err != nil { diff --git a/octopusdeploy/resource_listening_tentacle_deployment_target_test.go b/octopusdeploy/resource_listening_tentacle_deployment_target_test.go index c7b861f10..b55ddbac8 100644 --- a/octopusdeploy/resource_listening_tentacle_deployment_target_test.go +++ b/octopusdeploy/resource_listening_tentacle_deployment_target_test.go @@ -6,14 +6,13 @@ import ( internaltest "github.com/OctopusDeploy/terraform-provider-octopusdeploy/internal/test" "github.com/OctopusSolutionsEngineering/OctopusTerraformTestFramework/octoclient" "github.com/OctopusSolutionsEngineering/OctopusTerraformTestFramework/test" - "path/filepath" - "testing" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" + "path/filepath" ) -func TestAccListeningTentacleDeploymentTarget(t *testing.T) { +func (suite *IntegrationTestSuite) TestAccListeningTentacleDeploymentTarget() { + t := suite.T() SkipCI(t, "Error: Missing required argument") options := internaltest.NewListeningTentacleDeploymentTargetTestOptions() @@ -126,8 +125,9 @@ func testAccListeningTentacleDeploymentTargetCheckDestroy(s *terraform.State) er } // TestListeningTargetResource verifies that a listening machine can be reimported with the correct settings -func TestListeningTargetResource(t *testing.T) { +func (suite *IntegrationTestSuite) TestListeningTargetResource() { testFramework := test.OctopusContainerTest{} + t := suite.T() newSpaceId, err := testFramework.Act(t, octoContainer, "../terraform", "31-listeningtarget", []string{}) if err != nil { diff --git a/octopusdeploy/resource_machine_policy_test.go b/octopusdeploy/resource_machine_policy_test.go index ef262fda3..8271b5703 100644 --- a/octopusdeploy/resource_machine_policy_test.go +++ b/octopusdeploy/resource_machine_policy_test.go @@ -6,7 +6,6 @@ import ( "github.com/OctopusSolutionsEngineering/OctopusTerraformTestFramework/octoclient" "github.com/OctopusSolutionsEngineering/OctopusTerraformTestFramework/test" "strings" - "testing" ) // import ( @@ -156,8 +155,9 @@ import ( // } // TestMachinePolicyResource verifies that a machine policies can be reimported with the correct settings -func TestMachinePolicyResource(t *testing.T) { +func (suite *IntegrationTestSuite) TestMachinePolicyResource() { testFramework := test.OctopusContainerTest{} + t := suite.T() newSpaceId, err := testFramework.Act(t, octoContainer, "../terraform", "27-machinepolicy", []string{}) if err != nil { diff --git a/octopusdeploy/resource_offline_package_drop_deployment_target_test.go b/octopusdeploy/resource_offline_package_drop_deployment_target_test.go index 2a9ef2091..f0e4c9f30 100644 --- a/octopusdeploy/resource_offline_package_drop_deployment_target_test.go +++ b/octopusdeploy/resource_offline_package_drop_deployment_target_test.go @@ -5,12 +5,12 @@ import ( "github.com/OctopusSolutionsEngineering/OctopusTerraformTestFramework/octoclient" "github.com/OctopusSolutionsEngineering/OctopusTerraformTestFramework/test" "path/filepath" - "testing" ) // TestOfflineDropTargetResource verifies that an offline drop can be reimported with the correct settings -func TestOfflineDropTargetResource(t *testing.T) { +func (suite *IntegrationTestSuite) TestOfflineDropTargetResource() { testFramework := test.OctopusContainerTest{} + t := suite.T() newSpaceId, err := testFramework.Act(t, octoContainer, "../terraform", "34-offlinedroptarget", []string{}) if err != nil { diff --git a/octopusdeploy/resource_polling_subscription_id_test.go b/octopusdeploy/resource_polling_subscription_id_test.go index e1616b98a..464da31fb 100644 --- a/octopusdeploy/resource_polling_subscription_id_test.go +++ b/octopusdeploy/resource_polling_subscription_id_test.go @@ -4,11 +4,11 @@ import ( "github.com/OctopusSolutionsEngineering/OctopusTerraformTestFramework/test" "net/url" "path/filepath" - "testing" ) -func TestPollingSubscriptionIdResource(t *testing.T) { +func (suite *IntegrationTestSuite) TestPollingSubscriptionIdResource() { testFramework := test.OctopusContainerTest{} + t := suite.T() _, err := testFramework.Act(t, octoContainer, "../terraform", "56-pollingsubscriptionid", []string{}) if err != nil { diff --git a/octopusdeploy/resource_polling_tentacle_deployment_target_test.go b/octopusdeploy/resource_polling_tentacle_deployment_target_test.go index d2d6d032c..d64800e41 100644 --- a/octopusdeploy/resource_polling_tentacle_deployment_target_test.go +++ b/octopusdeploy/resource_polling_tentacle_deployment_target_test.go @@ -5,12 +5,12 @@ import ( "github.com/OctopusSolutionsEngineering/OctopusTerraformTestFramework/octoclient" "github.com/OctopusSolutionsEngineering/OctopusTerraformTestFramework/test" "path/filepath" - "testing" ) // TestPollingTargetResource verifies that a polling machine can be reimported with the correct settings -func TestPollingTargetResource(t *testing.T) { +func (suite *IntegrationTestSuite) TestPollingTargetResource() { testFramework := test.OctopusContainerTest{} + t := suite.T() newSpaceId, err := testFramework.Act(t, octoContainer, "../terraform", "32-pollingtarget", []string{}) if err != nil { diff --git a/octopusdeploy/resource_project_deployment_target_trigger_test.go b/octopusdeploy/resource_project_deployment_target_trigger_test.go index c33b07040..00c0df647 100644 --- a/octopusdeploy/resource_project_deployment_target_trigger_test.go +++ b/octopusdeploy/resource_project_deployment_target_trigger_test.go @@ -6,7 +6,6 @@ import ( "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/projects" "github.com/OctopusSolutionsEngineering/OctopusTerraformTestFramework/octoclient" "github.com/OctopusSolutionsEngineering/OctopusTerraformTestFramework/test" - "testing" ) // import ( @@ -173,8 +172,9 @@ import ( // } // TestProjectTriggerResource verifies that a project trigger can be reimported with the correct settings -func TestProjectTriggerResource(t *testing.T) { +func (suite *IntegrationTestSuite) TestProjectTriggerResource() { testFramework := test.OctopusContainerTest{} + t := suite.T() newSpaceId, err := testFramework.Act(t, octoContainer, "../terraform", "28-projecttrigger", []string{}) if err != nil { diff --git a/octopusdeploy/resource_project_group_test.go b/octopusdeploy/resource_project_group_test.go index e99d2a079..8325148c0 100644 --- a/octopusdeploy/resource_project_group_test.go +++ b/octopusdeploy/resource_project_group_test.go @@ -2,19 +2,18 @@ package octopusdeploy import ( "fmt" - "testing" - "github.com/OctopusDeploy/terraform-provider-octopusdeploy/internal/test" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" ) -func TestAccProjectGroup(t *testing.T) { +func (suite *IntegrationTestSuite) TestAccProjectGroup() { options := test.NewProjectGroupTestOptions() + t := suite.T() resource.Test(t, resource.TestCase{ - CheckDestroy: testProjectGroupDestroy, - PreCheck: func() { testAccPreCheck(t) }, + CheckDestroy: testProjectGroupDestroy, + PreCheck: func() { testAccPreCheck(t) }, ProtoV6ProviderFactories: ProtoV6ProviderFactories(), Steps: []resource.TestStep{ { diff --git a/octopusdeploy/resource_project_scheduled_trigger_test.go b/octopusdeploy/resource_project_scheduled_trigger_test.go index 4eaa84754..ee817a990 100644 --- a/octopusdeploy/resource_project_scheduled_trigger_test.go +++ b/octopusdeploy/resource_project_scheduled_trigger_test.go @@ -6,11 +6,11 @@ import ( "github.com/OctopusSolutionsEngineering/OctopusTerraformTestFramework/octoclient" "github.com/OctopusSolutionsEngineering/OctopusTerraformTestFramework/test" stdslices "slices" - "testing" ) -func TestProjectScheduledTriggerResources(t *testing.T) { +func (suite *IntegrationTestSuite) TestProjectScheduledTriggerResources() { testFramework := test.OctopusContainerTest{} + t := suite.T() newSpaceId, err := testFramework.Act(t, octoContainer, "../terraform", "53-scheduledprojecttrigger", []string{}) // Assert diff --git a/octopusdeploy/resource_project_test.go b/octopusdeploy/resource_project_test.go index c8b1ff354..9a03ec6a2 100644 --- a/octopusdeploy/resource_project_test.go +++ b/octopusdeploy/resource_project_test.go @@ -4,24 +4,23 @@ import ( "fmt" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/projects" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/spaces" + internaltest "github.com/OctopusDeploy/terraform-provider-octopusdeploy/internal/test" "github.com/OctopusSolutionsEngineering/OctopusTerraformTestFramework/octoclient" "github.com/OctopusSolutionsEngineering/OctopusTerraformTestFramework/test" - "os" - "path/filepath" - "sort" - "testing" - - internaltest "github.com/OctopusDeploy/terraform-provider-octopusdeploy/internal/test" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/acctest" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" + "os" + "path/filepath" + "sort" ) -func TestAccProjectBasic(t *testing.T) { +func (suite *IntegrationTestSuite) TestAccProjectBasic() { lifecycleTestOptions := internaltest.NewLifecycleTestOptions() projectGroupTestOptions := internaltest.NewProjectGroupTestOptions() projectTestOptions := internaltest.NewProjectTestOptions(lifecycleTestOptions, projectGroupTestOptions) projectTestOptions.Resource.IsDisabled = true + t := suite.T() resource.Test(t, resource.TestCase{ CheckDestroy: resource.ComposeTestCheckFunc( @@ -102,13 +101,14 @@ func testAccProjectWithTemplate(localName string, name string, lifecycleLocalNam }`, localName, lifecycleLocalName, name, projectGroupLocalName) } -func TestAccProjectWithUpdate(t *testing.T) { +func (suite *IntegrationTestSuite) TestAccProjectWithUpdate() { lifecycleLocalName := acctest.RandStringFromCharSet(20, acctest.CharSetAlpha) lifecycleName := acctest.RandStringFromCharSet(20, acctest.CharSetAlpha) projectGroupLocalName := acctest.RandStringFromCharSet(20, acctest.CharSetAlpha) projectGroupName := acctest.RandStringFromCharSet(20, acctest.CharSetAlpha) localName := acctest.RandStringFromCharSet(20, acctest.CharSetAlpha) prefix := "octopusdeploy_project." + localName + t := suite.T() description := acctest.RandStringFromCharSet(20, acctest.CharSetAlpha) name := acctest.RandStringFromCharSet(20, acctest.CharSetAlpha) @@ -249,8 +249,9 @@ func testAccProjectCheckExists() resource.TestCheckFunc { } // TestProjectResource verifies that a project can be reimported with the correct settings -func TestProjectResource(t *testing.T) { +func (suite *IntegrationTestSuite) TestProjectResource() { testFramework := test.OctopusContainerTest{} + t := suite.T() newSpaceId, err := testFramework.Act(t, octoContainer, "../terraform", "19-project", []string{}) if err != nil { @@ -337,8 +338,9 @@ func TestProjectResource(t *testing.T) { } } -func TestProjectInSpaceResource(t *testing.T) { +func (suite *IntegrationTestSuite) TestProjectInSpaceResource() { testFramework := test.OctopusContainerTest{} + t := suite.T() newSpaceId, err := testFramework.Act(t, octoContainer, "../terraform", "19b-projectspace", []string{}) if err != nil { @@ -418,7 +420,8 @@ func TestProjectInSpaceResource(t *testing.T) { } // TestProjectWithGitUsernameExport verifies that a project can be reimported with the correct git settings -func TestProjectWithGitUsernameExport(t *testing.T) { +func (suite *IntegrationTestSuite) TestProjectWithGitUsernameExport() { + t := suite.T() if os.Getenv("GIT_CREDENTIAL") == "" { t.Fatal("The GIT_CREDENTIAL environment variable must be set") } @@ -441,8 +444,9 @@ func TestProjectWithGitUsernameExport(t *testing.T) { } // TestProjectWithDollarSignsExport verifies that a project can be reimported with terraform string interpolation -func TestProjectWithDollarSignsExport(t *testing.T) { +func (suite *IntegrationTestSuite) TestProjectWithDollarSignsExport() { testFramework := test.OctopusContainerTest{} + t := suite.T() newSpaceId, err := testFramework.Act(t, octoContainer, "../terraform", "40-escapedollar", []string{}) @@ -471,8 +475,9 @@ func TestProjectWithDollarSignsExport(t *testing.T) { // TestProjectTerraformInlineScriptExport verifies that a project can be reimported with a terraform inline template step. // See https://github.com/OctopusDeployLabs/terraform-provider-octopusdeploy/issues/478 -func TestProjectTerraformInlineScriptExport(t *testing.T) { +func (suite *IntegrationTestSuite) TestProjectTerraformInlineScriptExport() { testFramework := test.OctopusContainerTest{} + t := suite.T() newSpaceId, err := testFramework.Act(t, octoContainer, "../terraform", "41-terraforminlinescript", []string{}) @@ -507,8 +512,9 @@ func TestProjectTerraformInlineScriptExport(t *testing.T) { // TestProjectTerraformPackageScriptExport verifies that a project can be reimported with a terraform package template step. // See https://github.com/OctopusDeployLabs/terraform-provider-octopusdeploy/issues/478 -func TestProjectTerraformPackageScriptExport(t *testing.T) { +func (suite *IntegrationTestSuite) TestProjectTerraformPackageScriptExport() { testFramework := test.OctopusContainerTest{} + t := suite.T() newSpaceId, err := testFramework.Act(t, octoContainer, "../terraform", "42-terraformpackagescript", []string{}) if err != nil { @@ -545,8 +551,9 @@ func TestProjectTerraformPackageScriptExport(t *testing.T) { } // TestProjectWithScriptActions verifies that a project with a plain script step can be applied and reapplied -func TestProjectWithScriptActions(t *testing.T) { +func (suite *IntegrationTestSuite) TestProjectWithScriptActions() { testFramework := test.OctopusContainerTest{} + t := suite.T() newSpaceId, err := testFramework.Act(t, octoContainer, "../terraform", "45-projectwithscriptactions", []string{}) if err != nil { diff --git a/octopusdeploy/resource_runbook_process_test.go b/octopusdeploy/resource_runbook_process_test.go index 0f1de80d0..12ba9e426 100644 --- a/octopusdeploy/resource_runbook_process_test.go +++ b/octopusdeploy/resource_runbook_process_test.go @@ -5,12 +5,12 @@ import ( "github.com/OctopusSolutionsEngineering/OctopusTerraformTestFramework/octoclient" "github.com/OctopusSolutionsEngineering/OctopusTerraformTestFramework/test" "strings" - "testing" ) // TestRunbookResource verifies that a runbook can be reimported with the correct settings -func TestRunbookResource(t *testing.T) { +func (suite *IntegrationTestSuite) TestRunbookResource() { testFramework := test.OctopusContainerTest{} + t := suite.T() newSpaceId, err := testFramework.Act(t, octoContainer, "../terraform", "46-runbooks", []string{}) if err != nil { diff --git a/octopusdeploy/resource_scoped_user_role_test.go b/octopusdeploy/resource_scoped_user_role_test.go index af99a2ada..de69d2941 100644 --- a/octopusdeploy/resource_scoped_user_role_test.go +++ b/octopusdeploy/resource_scoped_user_role_test.go @@ -2,15 +2,13 @@ package octopusdeploy import ( "fmt" - "testing" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/acctest" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" ) -func TestAccScopedUserRole(t *testing.T) { - SkipCI(t, "Error: octopus deploy api returned an error on endpoint /api/scopeduserroles - [You cannot use a role with Space level permissions at the System level. Space level permissions: AccountCreate]") +func (suite *IntegrationTestSuite) TestAccScopedUserRole() { + SkipCI(suite.T(), "Error: octopus deploy api returned an error on endpoint /api/scopeduserroles - [You cannot use a role with Space level permissions at the System level. Space level permissions: AccountCreate]") localName := acctest.RandStringFromCharSet(20, acctest.CharSetAlpha) teamResource := "octopusdeploy_team." + localName environmentResource := "octopusdeploy_environment." + localName @@ -22,9 +20,9 @@ func TestAccScopedUserRole(t *testing.T) { spaceID := acctest.RandStringFromCharSet(20, acctest.CharSetAlpha) - resource.Test(t, resource.TestCase{ + resource.Test(suite.T(), resource.TestCase{ CheckDestroy: testAccScopedUserRoleCheckDestroy, - PreCheck: func() { testAccPreCheck(t) }, + PreCheck: func() { testAccPreCheck(suite.T()) }, ProtoV6ProviderFactories: ProtoV6ProviderFactories(), Steps: []resource.TestStep{ { diff --git a/octopusdeploy/resource_script_module_test.go b/octopusdeploy/resource_script_module_test.go index 3893ad972..f6452d8b9 100644 --- a/octopusdeploy/resource_script_module_test.go +++ b/octopusdeploy/resource_script_module_test.go @@ -5,15 +5,13 @@ import ( "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/variables" "github.com/OctopusSolutionsEngineering/OctopusTerraformTestFramework/octoclient" "github.com/OctopusSolutionsEngineering/OctopusTerraformTestFramework/test" - "path/filepath" - "testing" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/acctest" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" + "path/filepath" ) -func TestAccOctopusDeployScriptModuleBasic(t *testing.T) { +func (suite *IntegrationTestSuite) TestAccOctopusDeployScriptModuleBasic() { localName := acctest.RandStringFromCharSet(20, acctest.CharSetAlpha) prefix := "octopusdeploy_script_module." + localName @@ -22,9 +20,9 @@ func TestAccOctopusDeployScriptModuleBasic(t *testing.T) { name := acctest.RandStringFromCharSet(20, acctest.CharSetAlpha) syntax := "Bash" - resource.Test(t, resource.TestCase{ + resource.Test(suite.T(), resource.TestCase{ CheckDestroy: testScriptModuleCheckDestroy, - PreCheck: func() { testAccPreCheck(t) }, + PreCheck: func() { testAccPreCheck(suite.T()) }, ProtoV6ProviderFactories: ProtoV6ProviderFactories(), Steps: []resource.TestStep{ { @@ -81,8 +79,9 @@ func testScriptModuleExists(n string) resource.TestCheckFunc { } // TestScriptModuleResource verifies that a script module set can be reimported with the correct settings -func TestScriptModuleResource(t *testing.T) { +func (suite *IntegrationTestSuite) TestScriptModuleResource() { testFramework := test.OctopusContainerTest{} + t := suite.T() newSpaceId, err := testFramework.Act(t, octoContainer, "../terraform", "23-scriptmodule", []string{}) if err != nil { diff --git a/octopusdeploy/resource_space_integration_test.go b/octopusdeploy/resource_space_integration_test.go index 1bef05735..81b030048 100644 --- a/octopusdeploy/resource_space_integration_test.go +++ b/octopusdeploy/resource_space_integration_test.go @@ -4,14 +4,13 @@ import ( "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/spaces" "github.com/OctopusSolutionsEngineering/OctopusTerraformTestFramework/octoclient" "github.com/OctopusSolutionsEngineering/OctopusTerraformTestFramework/test" - "testing" - "k8s.io/utils/strings/slices" ) // TestSpaceResource verifies that a space can be reimported with the correct settings -func TestSpaceResource(t *testing.T) { +func (suite *IntegrationTestSuite) TestSpaceResource() { testFramework := test.OctopusContainerTest{} + t := suite.T() newSpaceId, err := testFramework.Act(t, octoContainer, "../terraform", "1-singlespace", []string{}) if err != nil { @@ -32,8 +31,8 @@ func TestSpaceResource(t *testing.T) { t.Fatal(err.Error()) } - if space.Description != "TestSpaceResource" { - t.Fatalf("New space must have the description \"TestSpaceResource\"") + if space.Description != "TestSdkIntegrationTestSuite/TestSpaceResource" { + t.Fatalf("New space must have the description \"TestSdkIntegrationTestSuite/TestSpaceResource") } if space.IsDefault { diff --git a/octopusdeploy/resource_space_test.go b/octopusdeploy/resource_space_test.go index 3cca37024..1f37189fc 100644 --- a/octopusdeploy/resource_space_test.go +++ b/octopusdeploy/resource_space_test.go @@ -2,17 +2,16 @@ package octopusdeploy import ( "fmt" - "testing" - "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/spaces" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/acctest" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" ) -func TestAccSpaceImportBasic(t *testing.T) { +func (suite *IntegrationTestSuite) TestAccSpaceImportBasic() { localName := acctest.RandStringFromCharSet(20, acctest.CharSetAlpha) resourceName := "octopusdeploy_space." + localName + t := suite.T() name := acctest.RandStringFromCharSet(20, acctest.CharSetAlpha) slug := acctest.RandStringFromCharSet(20, acctest.CharSetAlpha) @@ -34,12 +33,13 @@ func TestAccSpaceImportBasic(t *testing.T) { }) } -func TestAccSpaceBasic(t *testing.T) { +func (suite *IntegrationTestSuite) TestAccSpaceBasic() { localName := acctest.RandStringFromCharSet(20, acctest.CharSetAlpha) name := acctest.RandStringFromCharSet(20, acctest.CharSetAlpha) newName := acctest.RandStringFromCharSet(20, acctest.CharSetAlpha) slug := acctest.RandStringFromCharSet(20, acctest.CharSetAlpha) prefix := "octopusdeploy_space." + localName + t := suite.T() resource.Test(t, resource.TestCase{ CheckDestroy: testAccSpaceCheckDestroy, diff --git a/octopusdeploy/resource_ssh_connection_deployment_target_test.go b/octopusdeploy/resource_ssh_connection_deployment_target_test.go index e8a6b1f74..12214489e 100644 --- a/octopusdeploy/resource_ssh_connection_deployment_target_test.go +++ b/octopusdeploy/resource_ssh_connection_deployment_target_test.go @@ -5,12 +5,12 @@ import ( "github.com/OctopusSolutionsEngineering/OctopusTerraformTestFramework/octoclient" "github.com/OctopusSolutionsEngineering/OctopusTerraformTestFramework/test" "path/filepath" - "testing" ) // TestSshTargetResource verifies that a ssh machine can be reimported with the correct settings -func TestSshTargetResource(t *testing.T) { +func (suite *IntegrationTestSuite) TestSshTargetResource() { testFramework := test.OctopusContainerTest{} + t := suite.T() newSpaceId, err := testFramework.Act(t, octoContainer, "../terraform", "30-sshtarget", []string{ "-var=account_ec2_sydney=LS0tLS1CRUdJTiBFTkNSWVBURUQgUFJJVkFURSBLRVktLS0tLQpNSUlKbkRCT0Jna3Foa2lHOXcwQkJRMHdRVEFwQmdrcWhraUc5dzBCQlF3d0hBUUlwNEUxV1ZrejJEd0NBZ2dBCk1Bd0dDQ3FHU0liM0RRSUpCUUF3RkFZSUtvWklodmNOQXdjRUNIemFuVE1QbHA4ZkJJSUpTSncrdW5BL2ZaVFUKRGdrdWk2QnhOY0REUFg3UHZJZmNXU1dTc3V3YWRhYXdkVEdjY1JVd3pGNTNmRWJTUXJBYzJuWFkwUWVVcU1wcAo4QmdXUUthWlB3MEdqck5OQVJaTy9QYklxaU5ERFMybVRSekZidzREcFY5aDdlblZjL1ZPNlhJdzlxYVYzendlCnhEejdZSkJ2ckhmWHNmTmx1blErYTZGdlRUVkVyWkE1Ukp1dEZUVnhUWVR1Z3lvWWNXZzAzQWlsMDh3eDhyTHkKUkgvTjNjRlEzaEtLcVZuSHQvdnNZUUhTMnJJYkt0RTluelFPWDRxRDdVYXM3Z0c0L2ZkcmZQZjZFWTR1aGpBcApUeGZRTDUzcTBQZG85T09MZlRReFRxakVNaFpidjV1aEN5d0N2VHdWTmVLZ2MzN1pqdDNPSjI3NTB3U2t1TFZvCnllR0VaQmtML1VONjJjTUJuYlFsSTEzR2FXejBHZ0NJNGkwS3UvRmE4aHJZQTQwcHVFdkEwZFBYcVFGMDhYbFYKM1RJUEhGRWdBWlJpTmpJWmFyQW00THdnL1F4Z203OUR1SVM3VHh6RCtpN1pNSmsydjI1ck14Ly9MMXNNUFBtOQpWaXBwVnpLZmpqRmpwTDVjcVJucC9UdUZSVWpHaDZWMFBXVVk1eTVzYjJBWHpuSGZVd1lqeFNoUjBKWXpXejAwCjNHbklwNnlJa1UvL3dFVGJLcVliMjd0RjdETm1WMUxXQzl0ell1dm4yK2EwQkpnU0Jlc3c4WFJ1WWorQS92bVcKWk1YbkF2anZXR3RBUzA4d0ZOV3F3QUtMbzJYUHBXWGVMa3BZUHo1ZnY2QnJaNVNwYTg4UFhsa1VmOVF0VHRobwprZFlGOWVMdk5hTXpSSWJhbmRGWjdLcHUvN2I3L0tDWE9rMUhMOUxvdEpwY2tJdTAxWS81TnQwOHp5cEVQQ1RzClVGWG5DODNqK2tWMktndG5XcXlEL2k3Z1dwaHJSK0IrNE9tM3VZU1RuY042a2d6ZkV3WldpUVA3ZkpiNlYwTHoKc29yU09sK2g2WDRsMC9oRVdScktVQTBrOXpPZU9TQXhlbmpVUXFReWdUd0RqQTJWbTdSZXI2ZElDMVBwNmVETgpBVEJ0ME1NZjJJTytxbTJtK0VLd1FVSXY4ZXdpdEpab016MFBaOHB6WEM0ZFMyRTErZzZmbnE2UGJ5WWRISDJnCmVraXk4Y2duVVJmdHJFaVoyMUxpMWdpdTJaeVM5QUc0Z1ZuT0E1Y05oSzZtRDJUaGl5UUl2M09yUDA0aDFTNlEKQUdGeGJONEhZK0tCYnVITTYwRG1PQXR5c3o4QkJheHFwWjlXQkVhV01ubFB6eEI2SnFqTGJrZ1BkQ2wycytUWAphcWx0UDd6QkpaenVTeVNQc2tQR1NBREUvaEF4eDJFM1RQeWNhQlhQRVFUM2VkZmNsM09nYXRmeHBSYXJLV09PCnFHM2lteW42ZzJiNjhWTlBDSnBTYTNKZ1Axb0NNVlBpa2RCSEdSVUV3N2dXTlJVOFpXRVJuS292M2c0MnQ4dkEKU2Z0a3VMdkhoUnlPQW91SUVsNjJIems0WC9CeVVOQ2J3MW50RzFQeHpSaERaV2dPaVhPNi94WFByRlpKa3BtcQpZUUE5dW83OVdKZy9zSWxucFJCdFlUbUh4eU9mNk12R2svdXlkZExkcmZ6MHB6QUVmWm11YTVocWh5M2Y4YlNJCmpxMlJwUHE3eHJ1Y2djbFAwTWFjdHkrbm9wa0N4M0lNRUE4NE9MQ3dxZjVtemtwY0U1M3hGaU1hcXZTK0dHZmkKZlZnUGpXTXRzMFhjdEtCV2tUbVFFN3MxSE5EV0g1dlpJaDY2WTZncXR0cjU2VGdtcHRLWHBVdUJ1MEdERFBQbwp1aGI4TnVRRjZwNHNoM1dDbXlzTU9uSW5jaXRxZWE4NTFEMmloK2lIY3VqcnJidkVYZGtjMnlxUHBtK3Q3SXBvCm1zWkxVemdXRlZpNWY3KzZiZU56dGJ3T2tmYmdlQVAyaklHTzdtR1pKWWM0L1d1eXBqeVRKNlBQVC9IMUc3K3QKUTh5R3FDV3BzNFdQM2srR3hrbW90cnFROFcxa0J1RDJxTEdmSTdMMGZUVE9lWk0vQUZ1VDJVSkcxKzQ2czJVVwp2RlF2VUJmZ0dTWlh3c1VUeGJRTlZNaTJib1BCRkNxbUY2VmJTcmw2YVgrSm1NNVhySUlqUUhGUFZWVGxzeUtpClVDUC9PQTJOWlREdW9IcC9EM0s1Qjh5MlIyUTlqZlJ0RkcwL0dnMktCbCtObzdTbXlPcWlsUlNkZ1VJb0p5QkcKRGovZXJ4ZkZNMlc3WTVsNGZ2ZlNpdU1OZmlUTVdkY3cxSStnVkpGMC9mTHRpYkNoUlg0OTlIRWlXUHZkTGFKMwppcDJEYU9ReS9QZG5zK3hvaWlMNWtHV25BVUVwanNjWno0YU5DZFowOXRUb1FhK2RZd3g1R1ovNUtmbnVpTURnClBrWjNXalFpOVlZRWFXbVIvQ2JmMjAyRXdoNjdIZzVqWE5kb0RNendXT0V4RFNkVFFYZVdzUUI0LzNzcjE2S2MKeitGN2xhOXhHVEVhTDllQitwcjY5L2JjekJLMGVkNXUxYUgxcXR3cjcrMmliNmZDdlMyblRGQTM1ZG50YXZlUwp4VUJVZ0NzRzVhTTl4b2pIQ0o4RzRFMm9iRUEwUDg2SFlqZEJJSXF5U0txZWtQYmFybW4xR1JrdUVlbU5hTVdyCkM2bWZqUXR5V2ZMWnlSbUlhL1dkSVgzYXhqZHhYa3kydm4yNVV6MXZRNklrNnRJcktPYUJnRUY1cmYwY014dTUKN1BYeTk0dnc1QjE0Vlcra2JqQnkyY3hIajJhWnJEaE53UnVQNlpIckg5MHZuN2NmYjYwU0twRWxxdmZwdlN0VQpvQnVXQlFEUUE3bHpZajhhT3BHend3LzlYTjI5MGJrUnd4elVZRTBxOVl4bS9VSHJTNUlyRWtKSml2SUlEb3hICjF4VTVLd2ErbERvWDJNcERrZlBQVE9XSjVqZG8wbXNsN0dBTmc1WGhERnBpb2hFMEdSS2lGVytYcjBsYkJKU2oKUkxibytrbzhncXU2WHB0OWU4U0Y5OEJ4bFpEcFBVMG5PcGRrTmxwTVpKYVlpaUUzRjRFRG9DcE56bmxpY2JrcApjZ2FrcGVrbS9YS21RSlJxWElXci8wM29SdUVFTXBxZzlRbjdWRG8zR0FiUTlnNUR5U1Bid0xvT25xQ0V3WGFJCkF6alFzWU4rc3VRd2FqZHFUcEthZ1FCbWRaMmdNZDBTMTV1Ukt6c2wxOHgzK1JabmRiNWoxNjNuV0NkMlQ5VDgKald3NURISDgvVUFkSGZoOHh0RTJ6bWRHbEg5T3I5U2hIMzViMWgxVm8rU2pNMzRPeWpwVjB3TmNVL1psOTBUdAp1WnJwYnBwTXZCZUVmRzZTczVXVGhySm9LaGl0RkNwWlVqaDZvdnk3Mzd6ditKaUc4aDRBNG1GTmRPSUtBd0I0Cmp2Nms3V3poUVlEa2Q0ZXRoajNndVJCTGZQNThNVEJKaWhZemVINkUzclhjSGE5b0xnREgzczd4bU8yVEtUY24Kd3VIM3AvdC9WWFN3UGJ0QXBXUXdTRFNKSnA5WkF4S0Q1eVdmd3lTU2ZQVGtwM2c1b2NmKzBhSk1Kc2FkU3lwNQpNR1Vic1oxd1hTN2RXMDhOYXZ2WmpmbElNUm8wUFZDbkRVcFp1bjJuekhTRGJDSjB1M0ZYd1lFQzFFejlJUnN0ClJFbDdpdTZQRlVMSldSU0V0SzBKY1lLS0ltNXhQWHIvbTdPc2duMUNJL0F0cTkrWEFjODk1MGVxeTRwTFVQYkYKZkhFOFhVYWFzUU82MDJTeGpnOTZZaWJ3ZnFyTDF2Vjd1MitUYzJleUZ1N3oxUGRPZDQyWko5M2wvM3lOUW92egora0JuQVdObzZ3WnNKSitHNDZDODNYRVBLM0h1bGw1dFg2UDU4NUQ1b3o5U1oyZGlTd1FyVFN1THVSL0JCQUpVCmd1K2FITkJGRmVtUXNEL2QxMllud1h3d3FkZXVaMDVmQlFiWUREdldOM3daUjJJeHZpd1E0bjZjZWl3OUZ4QmcKbWlzMFBGY2NZOWl0SnJrYXlWQVVZUFZ3Sm5XSmZEK2pQNjJ3UWZJWmhhbFQrZDJpUzVQaDEwdWlMNHEvY1JuYgo1c1Mvc2o0Tm5QYmpxc1ZmZWlKTEh3PT0KLS0tLS1FTkQgRU5DUllQVEVEIFBSSVZBVEUgS0VZLS0tLS0K", "-var=account_ec2_sydney_cert=whatever", diff --git a/octopusdeploy/resource_sshkey_account_test.go b/octopusdeploy/resource_sshkey_account_test.go index 0727785d6..a45945e6a 100644 --- a/octopusdeploy/resource_sshkey_account_test.go +++ b/octopusdeploy/resource_sshkey_account_test.go @@ -3,16 +3,14 @@ package octopusdeploy import ( "fmt" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/accounts" + "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/core" "github.com/OctopusSolutionsEngineering/OctopusTerraformTestFramework/octoclient" "github.com/OctopusSolutionsEngineering/OctopusTerraformTestFramework/test" - "testing" - - "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/core" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/acctest" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" ) -func TestSSHKeyBasic(t *testing.T) { +func (suite *IntegrationTestSuite) TestSSHKeyBasic() { localName := acctest.RandStringFromCharSet(20, acctest.CharSetAlpha) prefix := "octopusdeploy_ssh_key_account." + localName @@ -22,9 +20,9 @@ func TestSSHKeyBasic(t *testing.T) { tenantedDeploymentParticipation := core.TenantedDeploymentModeTenantedOrUntenanted username := acctest.RandStringFromCharSet(20, acctest.CharSetAlpha) - resource.Test(t, resource.TestCase{ + resource.Test(suite.T(), resource.TestCase{ CheckDestroy: testAccountCheckDestroy, - PreCheck: func() { testAccPreCheck(t) }, + PreCheck: func() { testAccPreCheck(suite.T()) }, ProtoV6ProviderFactories: ProtoV6ProviderFactories(), Steps: []resource.TestStep{ { @@ -52,8 +50,9 @@ func testSSHKeyBasic(localName string, name string, privateKeyFile string, usern } // TestSshAccountResource verifies that an SSH account can be reimported with the correct settings -func TestSshAccountResource(t *testing.T) { +func (suite *IntegrationTestSuite) TestSshAccountResource() { testFramework := test.OctopusContainerTest{} + t := suite.T() newSpaceId, err := testFramework.Act(t, octoContainer, "../terraform", "7-sshaccount", []string{}) if err != nil { diff --git a/octopusdeploy/resource_static_worker_pool_test.go b/octopusdeploy/resource_static_worker_pool_test.go index c90c18e84..35ed94703 100644 --- a/octopusdeploy/resource_static_worker_pool_test.go +++ b/octopusdeploy/resource_static_worker_pool_test.go @@ -5,16 +5,14 @@ import ( "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/workerpools" "github.com/OctopusSolutionsEngineering/OctopusTerraformTestFramework/octoclient" "github.com/OctopusSolutionsEngineering/OctopusTerraformTestFramework/test" - "path/filepath" - "strconv" - "testing" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/acctest" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" + "path/filepath" + "strconv" ) -func TestAccOctopusDeployStaticWorkerPoolBasic(t *testing.T) { +func (suite *IntegrationTestSuite) TestAccOctopusDeployStaticWorkerPoolBasic() { localName := acctest.RandStringFromCharSet(20, acctest.CharSetAlpha) prefix := "octopusdeploy_static_worker_pool." + localName @@ -22,6 +20,7 @@ func TestAccOctopusDeployStaticWorkerPoolBasic(t *testing.T) { description := acctest.RandStringFromCharSet(20, acctest.CharSetAlpha) isDefault := false sortOrder := acctest.RandIntRange(50, 100) + t := suite.T() resource.Test(t, resource.TestCase{ PreCheck: func() { testAccPreCheck(t) }, @@ -83,8 +82,9 @@ func testStaticWorkerPoolDestroy(s *terraform.State) error { } // TestWorkerPoolResource verifies that a static worker pool can be reimported with the correct settings -func TestWorkerPoolResource(t *testing.T) { +func (suite *IntegrationTestSuite) TestWorkerPoolResource() { testFramework := test.OctopusContainerTest{} + t := suite.T() newSpaceId, err := testFramework.Act(t, octoContainer, "../terraform", "15-workerpool", []string{}) if err != nil { diff --git a/octopusdeploy/resource_tag_set_test.go b/octopusdeploy/resource_tag_set_test.go index 06b1530ad..92a3b96a4 100644 --- a/octopusdeploy/resource_tag_set_test.go +++ b/octopusdeploy/resource_tag_set_test.go @@ -5,14 +5,13 @@ import ( "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/tagsets" "github.com/OctopusSolutionsEngineering/OctopusTerraformTestFramework/octoclient" "github.com/OctopusSolutionsEngineering/OctopusTerraformTestFramework/test" - "testing" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/acctest" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" ) -func TestAccOctopusDeployTagSetBasic(t *testing.T) { +func (suite *IntegrationTestSuite) TestAccOctopusDeployTagSetBasic() { + t := suite.T() SkipCI(t, " Error: Unsupported block type") localName := acctest.RandStringFromCharSet(20, acctest.CharSetAlpha) prefix := "octopusdeploy_tag_set." + localName @@ -94,7 +93,8 @@ func testTagSetDestroy(s *terraform.State) error { } // TestTagSetResource verifies that a tag set can be reimported with the correct settings -func TestTagSetResource(t *testing.T) { +func (suite *IntegrationTestSuite) TestTagSetResource() { + t := suite.T() SkipCI(t, " Error: Unsupported block type") testFramework := test.OctopusContainerTest{} newSpaceId, err := testFramework.Act(t, octoContainer, "../terraform", "21-tagset", []string{}) diff --git a/octopusdeploy/resource_team_test.go b/octopusdeploy/resource_team_test.go index 98e813cce..376f32654 100644 --- a/octopusdeploy/resource_team_test.go +++ b/octopusdeploy/resource_team_test.go @@ -2,14 +2,12 @@ package octopusdeploy import ( "fmt" - "testing" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/acctest" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" ) -func TestAccTeamBasic(t *testing.T) { +func (suite *IntegrationTestSuite) TestAccTeamBasic() { localName := acctest.RandStringFromCharSet(20, acctest.CharSetAlpha) resourceName := "octopusdeploy_team." + localName @@ -17,9 +15,9 @@ func TestAccTeamBasic(t *testing.T) { name := acctest.RandStringFromCharSet(20, acctest.CharSetAlpha) updatedDescription := acctest.RandStringFromCharSet(20, acctest.CharSetAlpha) - resource.Test(t, resource.TestCase{ + resource.Test(suite.T(), resource.TestCase{ CheckDestroy: testAccTeamCheckDestroy, - PreCheck: func() { testAccPreCheck(t) }, + PreCheck: func() { testAccPreCheck(suite.T()) }, ProtoV6ProviderFactories: ProtoV6ProviderFactories(), Steps: []resource.TestStep{ { @@ -42,8 +40,8 @@ func TestAccTeamBasic(t *testing.T) { }) } -func TestAccTeamUserRole(t *testing.T) { - SkipCI(t, "error creating user role for team Teams-3: octopus deploy api returned an error on endpoint /api/scopeduserroles - [You cannot use a role with Space level permissions at the System level. Space level permissions: AccountCreate]") +func (suite *IntegrationTestSuite) TestAccTeamUserRole() { + SkipCI(suite.T(), "error creating user role for team Teams-3: octopus deploy api returned an error on endpoint /api/scopeduserroles - [You cannot use a role with Space level permissions at the System level. Space level permissions: AccountCreate]") localName := acctest.RandStringFromCharSet(20, acctest.CharSetAlpha) resourceName := "octopusdeploy_team." + localName userRoleResource := "octopusdeploy_user_role." + localName @@ -53,9 +51,9 @@ func TestAccTeamUserRole(t *testing.T) { spaceID := acctest.RandStringFromCharSet(20, acctest.CharSetAlpha) - resource.Test(t, resource.TestCase{ + resource.Test(suite.T(), resource.TestCase{ CheckDestroy: testAccTeamCheckDestroy, - PreCheck: func() { testAccPreCheck(t) }, + PreCheck: func() { testAccPreCheck(suite.T()) }, ProtoV6ProviderFactories: ProtoV6ProviderFactories(), Steps: []resource.TestStep{ { diff --git a/octopusdeploy/resource_tenant_test.go b/octopusdeploy/resource_tenant_test.go index 96df4352f..3dee1527a 100644 --- a/octopusdeploy/resource_tenant_test.go +++ b/octopusdeploy/resource_tenant_test.go @@ -5,16 +5,13 @@ import ( "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/tenants" "github.com/OctopusSolutionsEngineering/OctopusTerraformTestFramework/octoclient" "github.com/OctopusSolutionsEngineering/OctopusTerraformTestFramework/test" - "path/filepath" - "testing" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/acctest" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" + "path/filepath" ) -func TestAccTenantBasic(t *testing.T) { - SkipCI(t, "project_environment have been refactor [deprecated] - will enable this test later after Ben fix") +func (suite *IntegrationTestSuite) TestAccTenantBasic() { lifecycleLocalName := acctest.RandStringFromCharSet(20, acctest.CharSetAlpha) lifecycleName := acctest.RandStringFromCharSet(20, acctest.CharSetAlpha) projectGroupLocalName := acctest.RandStringFromCharSet(20, acctest.CharSetAlpha) @@ -31,6 +28,7 @@ func TestAccTenantBasic(t *testing.T) { description := acctest.RandStringFromCharSet(20, acctest.CharSetAlpha) newDescription := acctest.RandStringFromCharSet(20, acctest.CharSetAlpha) + t := suite.T() resource.Test(t, resource.TestCase{ CheckDestroy: testAccTenantCheckDestroy, @@ -108,8 +106,9 @@ func testAccTenantCheckDestroy(s *terraform.State) error { } // TestTenantsResource verifies that a git credential can be reimported with the correct settings -func TestTenantsResource(t *testing.T) { +func (suite *IntegrationTestSuite) TestTenantsResource() { testFramework := test.OctopusContainerTest{} + t := suite.T() newSpaceId, err := testFramework.Act(t, octoContainer, "../terraform", "24-tenants", []string{}) if err != nil { diff --git a/octopusdeploy/resource_tentacle_certificate_test.go b/octopusdeploy/resource_tentacle_certificate_test.go index 483d08f08..4b652c7b4 100644 --- a/octopusdeploy/resource_tentacle_certificate_test.go +++ b/octopusdeploy/resource_tentacle_certificate_test.go @@ -3,11 +3,11 @@ package octopusdeploy import ( "github.com/OctopusSolutionsEngineering/OctopusTerraformTestFramework/test" "path/filepath" - "testing" ) -func TestTentacleCertificateResource(t *testing.T) { +func (suite *IntegrationTestSuite) TestTentacleCertificateResource() { testFramework := test.OctopusContainerTest{} + t := suite.T() _, err := testFramework.Act(t, octoContainer, "../terraform", "57-tentaclecertificate", []string{}) if err != nil { diff --git a/octopusdeploy/resource_token_account_test.go b/octopusdeploy/resource_token_account_test.go index 56e6720d1..2475e88bd 100644 --- a/octopusdeploy/resource_token_account_test.go +++ b/octopusdeploy/resource_token_account_test.go @@ -3,18 +3,17 @@ package octopusdeploy import ( "fmt" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/accounts" + "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/core" "github.com/OctopusSolutionsEngineering/OctopusTerraformTestFramework/octoclient" "github.com/OctopusSolutionsEngineering/OctopusTerraformTestFramework/test" - "testing" - - "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/core" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/acctest" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" ) -func TestTokenAccountBasic(t *testing.T) { +func (suite *IntegrationTestSuite) TestTokenAccountBasic() { localName := acctest.RandStringFromCharSet(20, acctest.CharSetAlpha) resourceName := "octopusdeploy_token_account." + localName + t := suite.T() description := acctest.RandStringFromCharSet(20, acctest.CharSetAlpha) name := acctest.RandStringFromCharSet(20, acctest.CharSetAlpha) @@ -53,8 +52,9 @@ func testTokenAccountBasic(localName string, description string, name string, te } // TestTokenAccountResource verifies that a token account can be reimported with the correct settings -func TestTokenAccountResource(t *testing.T) { +func (suite *IntegrationTestSuite) TestTokenAccountResource() { testFramework := test.OctopusContainerTest{} + t := suite.T() newSpaceId, err := testFramework.Act(t, octoContainer, "../terraform", "9-tokenaccount", []string{}) if err != nil { diff --git a/octopusdeploy/resource_user_role_test.go b/octopusdeploy/resource_user_role_test.go index b3b804dd4..339fa0f2d 100644 --- a/octopusdeploy/resource_user_role_test.go +++ b/octopusdeploy/resource_user_role_test.go @@ -2,20 +2,18 @@ package octopusdeploy import ( "fmt" - "testing" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/acctest" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" ) -func TestAccUserRoleBasic(t *testing.T) { +func (suite *IntegrationTestSuite) TestAccUserRoleBasic() { localName := acctest.RandStringFromCharSet(20, acctest.CharSetAlpha) name := acctest.RandStringFromCharSet(16, acctest.CharSetAlpha) - resource.Test(t, resource.TestCase{ - CheckDestroy: testAccUserRoleCheckDestroy, - PreCheck: func() { testAccPreCheck(t) }, + resource.Test(suite.T(), resource.TestCase{ + CheckDestroy: testAccUserRoleCheckDestroy, + PreCheck: func() { testAccPreCheck(suite.T()) }, ProtoV6ProviderFactories: ProtoV6ProviderFactories(), Steps: []resource.TestStep{ { @@ -25,13 +23,14 @@ func TestAccUserRoleBasic(t *testing.T) { }) } -func TestAccUserRolePermissions(t *testing.T) { +func (suite *IntegrationTestSuite) TestAccUserRolePermissions() { localName := acctest.RandStringFromCharSet(20, acctest.CharSetAlpha) name := acctest.RandStringFromCharSet(16, acctest.CharSetAlpha) + t := suite.T() resource.Test(t, resource.TestCase{ - CheckDestroy: testAccUserRoleCheckDestroy, - PreCheck: func() { testAccPreCheck(t) }, + CheckDestroy: testAccUserRoleCheckDestroy, + PreCheck: func() { testAccPreCheck(t) }, ProtoV6ProviderFactories: ProtoV6ProviderFactories(), Steps: []resource.TestStep{ { diff --git a/octopusdeploy/resource_user_test.go b/octopusdeploy/resource_user_test.go index e4e65cd68..6f4eddb79 100644 --- a/octopusdeploy/resource_user_test.go +++ b/octopusdeploy/resource_user_test.go @@ -6,16 +6,14 @@ import ( "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/users" "github.com/OctopusSolutionsEngineering/OctopusTerraformTestFramework/octoclient" "github.com/OctopusSolutionsEngineering/OctopusTerraformTestFramework/test" - "path/filepath" - "strconv" - "testing" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/acctest" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" + "path/filepath" + "strconv" ) -func TestAccUserImportBasic(t *testing.T) { +func (suite *IntegrationTestSuite) TestAccUserImportBasic() { localName := acctest.RandStringFromCharSet(20, acctest.CharSetAlpha) resourceName := "octopusdeploy_user." + localName @@ -23,6 +21,7 @@ func TestAccUserImportBasic(t *testing.T) { emailAddress := acctest.RandStringFromCharSet(20, acctest.CharSetAlpha) + "." + acctest.RandStringFromCharSet(20, acctest.CharSetAlpha) + "@example.com" password := acctest.RandStringFromCharSet(20, acctest.CharSetAlpha) username := acctest.RandStringFromCharSet(20, acctest.CharSetAlpha) + t := suite.T() resource.Test(t, resource.TestCase{ CheckDestroy: testAccUserCheckDestroy, @@ -42,7 +41,7 @@ func TestAccUserImportBasic(t *testing.T) { }) } -func TestAccUserBasic(t *testing.T) { +func (suite *IntegrationTestSuite) TestAccUserBasic() { localName := acctest.RandStringFromCharSet(20, acctest.CharSetAlpha) resourceName := "octopusdeploy_user." + localName @@ -52,6 +51,7 @@ func TestAccUserBasic(t *testing.T) { emailAddress := acctest.RandStringFromCharSet(20, acctest.CharSetAlpha) + "." + acctest.RandStringFromCharSet(20, acctest.CharSetAlpha) + "@example.com" password := acctest.RandStringFromCharSet(20, acctest.CharSetAlpha) username := acctest.RandStringFromCharSet(20, acctest.CharSetAlpha) + t := suite.T() resource.Test(t, resource.TestCase{ CheckDestroy: testAccUserCheckDestroy, @@ -136,8 +136,9 @@ func testAccUserCheckDestroy(s *terraform.State) error { } // TestProjectTerraformPackageScriptExport verifies that users and teams can be reimported -func TestUsersAndTeams(t *testing.T) { +func (suite *IntegrationTestSuite) TestUsersAndTeams() { testFramework := test.OctopusContainerTest{} + t := suite.T() newSpaceId, err := testFramework.Act(t, octoContainer, "../terraform", "43-users", []string{}) if err != nil { diff --git a/octopusdeploy/resource_username_password_account_integration_test.go b/octopusdeploy/resource_username_password_account_integration_test.go index b5ea00af4..6ed8834bb 100644 --- a/octopusdeploy/resource_username_password_account_integration_test.go +++ b/octopusdeploy/resource_username_password_account_integration_test.go @@ -4,12 +4,12 @@ import ( "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/accounts" "github.com/OctopusSolutionsEngineering/OctopusTerraformTestFramework/octoclient" "github.com/OctopusSolutionsEngineering/OctopusTerraformTestFramework/test" - "testing" ) // TestUsernamePasswordAccountResource verifies that a username/password account can be reimported with the correct settings -func TestUsernamePasswordAccountResource(t *testing.T) { +func (suite *IntegrationTestSuite) TestUsernamePasswordAccountResource() { testFramework := test.OctopusContainerTest{} + t := suite.T() newSpaceId, err := testFramework.Act(t, octoContainer, "../terraform", "5-userpassaccount", []string{}) if err != nil { diff --git a/octopusdeploy/resource_username_password_account_test.go b/octopusdeploy/resource_username_password_account_test.go index e1a29bd9f..1e5bfc222 100644 --- a/octopusdeploy/resource_username_password_account_test.go +++ b/octopusdeploy/resource_username_password_account_test.go @@ -2,20 +2,19 @@ package octopusdeploy import ( "fmt" + "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/core" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/projects" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/variables" "github.com/OctopusSolutionsEngineering/OctopusTerraformTestFramework/octoclient" "github.com/OctopusSolutionsEngineering/OctopusTerraformTestFramework/test" - "testing" - - "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/core" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/acctest" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" ) -func TestAccUsernamePasswordBasic(t *testing.T) { +func (suite *IntegrationTestSuite) TestAccUsernamePasswordBasic() { localName := acctest.RandStringFromCharSet(20, acctest.CharSetAlpha) resourceName := "octopusdeploy_username_password_account." + localName + t := suite.T() description := acctest.RandStringFromCharSet(20, acctest.CharSetAlpha) name := acctest.RandStringFromCharSet(20, acctest.CharSetAlpha) @@ -67,8 +66,9 @@ func testUsernamePasswordMinimum(localName string, name string, username string) // TestUsernamePasswordVariableResource verifies that a project variable referencing a username/password account // can be created -func TestUsernamePasswordVariableResource(t *testing.T) { +func (suite *IntegrationTestSuite) TestUsernamePasswordVariableResource() { testFramework := test.OctopusContainerTest{} + t := suite.T() newSpaceId, err := testFramework.Act(t, octoContainer, "../terraform", "54-usernamepasswordvariable", []string{}) if err != nil { diff --git a/octopusdeploy/resource_variable_test.go b/octopusdeploy/resource_variable_test.go index 2b83bab03..31087f54f 100644 --- a/octopusdeploy/resource_variable_test.go +++ b/octopusdeploy/resource_variable_test.go @@ -5,15 +5,14 @@ import ( "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/variables" "github.com/OctopusSolutionsEngineering/OctopusTerraformTestFramework/octoclient" "github.com/OctopusSolutionsEngineering/OctopusTerraformTestFramework/test" - "path/filepath" - "testing" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/acctest" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" + "path/filepath" ) -func TestAccOctopusDeployVariableBasic(t *testing.T) { +func (suite *IntegrationTestSuite) TestAccOctopusDeployVariableBasic() { + t := suite.T() SkipCI(t, "Octopus API error: The resource you requested was not found. []") localName := acctest.RandStringFromCharSet(20, acctest.CharSetAlpha) prefix := "octopusdeploy_variable." + localName @@ -223,8 +222,9 @@ func testVariableDestroy(s *terraform.State) error { } // TestVariableSetResource verifies that a variable set can be reimported with the correct settings -func TestVariableSetResource(t *testing.T) { +func (suite *IntegrationTestSuite) TestVariableSetResource() { testFramework := test.OctopusContainerTest{} + t := suite.T() newSpaceId, err := testFramework.Act(t, octoContainer, "../terraform", "18-variableset", []string{}) if err != nil { @@ -301,8 +301,9 @@ func TestVariableSetResource(t *testing.T) { } } -func TestVariableResource(t *testing.T) { +func (suite *IntegrationTestSuite) TestVariableResource() { testFramework := test.OctopusContainerTest{} + t := suite.T() newSpaceId, err := testFramework.Act(t, octoContainer, "../terraform", "49-variables", []string{}) if err != nil { diff --git a/octopusdeploy/schema_action_apply_terraform_template_test.go b/octopusdeploy/schema_action_apply_terraform_template_test.go index 193d21e4d..a9d31bbde 100644 --- a/octopusdeploy/schema_action_apply_terraform_template_test.go +++ b/octopusdeploy/schema_action_apply_terraform_template_test.go @@ -2,15 +2,14 @@ package octopusdeploy import ( "fmt" - "strconv" - "testing" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/acctest" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" + "strconv" ) -func TestAccOctopusDeployApplyTerraformAction(t *testing.T) { +func (suite *IntegrationTestSuite) TestAccOctopusDeployApplyTerraformAction() { + t := suite.T() allowPluginDownloads := acctest.RandIntRange(0, 2) == 0 applyParameters := acctest.RandStringFromCharSet(20, acctest.CharSetAlpha) initParameters := acctest.RandStringFromCharSet(20, acctest.CharSetAlpha) diff --git a/octopusdeploy/schema_action_deploy_kubernetes_secret_test.go b/octopusdeploy/schema_action_deploy_kubernetes_secret_test.go index f39adc325..8763d457c 100644 --- a/octopusdeploy/schema_action_deploy_kubernetes_secret_test.go +++ b/octopusdeploy/schema_action_deploy_kubernetes_secret_test.go @@ -2,20 +2,18 @@ package octopusdeploy import ( "fmt" - "testing" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" ) -func TestAccOctopusDeployDeployKubernetesSecretAction(t *testing.T) { - resource.Test(t, resource.TestCase{ +func (suite *IntegrationTestSuite) TestAccOctopusDeployDeployKubernetesSecretAction() { + resource.Test(suite.T(), resource.TestCase{ CheckDestroy: resource.ComposeTestCheckFunc( testAccProjectCheckDestroy, testAccProjectGroupCheckDestroy, testAccLifecycleCheckDestroy, ), - PreCheck: func() { testAccPreCheck(t) }, + PreCheck: func() { testAccPreCheck(suite.T()) }, ProtoV6ProviderFactories: ProtoV6ProviderFactories(), Steps: []resource.TestStep{ { diff --git a/octopusdeploy/schema_action_deploy_windows_service_test.go b/octopusdeploy/schema_action_deploy_windows_service_test.go index fb8d2db89..0844590dc 100644 --- a/octopusdeploy/schema_action_deploy_windows_service_test.go +++ b/octopusdeploy/schema_action_deploy_windows_service_test.go @@ -2,46 +2,44 @@ package octopusdeploy import ( "fmt" - "testing" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" ) -func TestAccOctopusDeployDeployWindowsServiceAction(t *testing.T) { - resource.Test(t, resource.TestCase{ +func (suite *IntegrationTestSuite) TestAccOctopusDeployDeployWindowsServiceAction() { + resource.Test(suite.T(), resource.TestCase{ CheckDestroy: resource.ComposeTestCheckFunc( testAccProjectCheckDestroy, testAccProjectGroupCheckDestroy, testAccLifecycleCheckDestroy, ), - PreCheck: func() { testAccPreCheck(t) }, + PreCheck: func() { testAccPreCheck(suite.T()) }, ProtoV6ProviderFactories: ProtoV6ProviderFactories(), Steps: []resource.TestStep{ { Config: testAccDeployWindowsServiceAction(), Check: resource.ComposeTestCheckFunc( - testAccCheckDeployWindowsServiceActionOrFeature("Octopus.WindowsService"), + testAccCheckDeployWindowsServiceActionOrFeature(suite, "Octopus.WindowsService"), ), }, }, }) } -func TestAccOctopusDeployWindowsServiceFeature(t *testing.T) { - resource.Test(t, resource.TestCase{ +func (suite *IntegrationTestSuite) TestAccOctopusDeployWindowsServiceFeature() { + resource.Test(suite.T(), resource.TestCase{ CheckDestroy: resource.ComposeTestCheckFunc( testAccProjectCheckDestroy, testAccProjectGroupCheckDestroy, testAccLifecycleCheckDestroy, ), - PreCheck: func() { testAccPreCheck(t) }, + PreCheck: func() { testAccPreCheck(suite.T()) }, ProtoV6ProviderFactories: ProtoV6ProviderFactories(), Steps: []resource.TestStep{ { Config: testAccWindowsServiceFeature(), Check: resource.ComposeTestCheckFunc( - testAccCheckDeployWindowsServiceActionOrFeature("Octopus.TentaclePackage"), + testAccCheckDeployWindowsServiceActionOrFeature(suite, "Octopus.TentaclePackage"), ), }, }, @@ -97,9 +95,9 @@ func testAccWindowsServiceFeature() string { `) } -func testAccCheckDeployWindowsServiceActionOrFeature(expectedActionType string) resource.TestCheckFunc { +func testAccCheckDeployWindowsServiceActionOrFeature(suite *IntegrationTestSuite, expectedActionType string) resource.TestCheckFunc { return func(s *terraform.State) error { - process, err := getDeploymentProcess(s, octoClient) + process, err := getDeploymentProcess(s, suite.octoClient) if err != nil { return err } diff --git a/octopusdeploy/schema_action_manual_intervention_test.go b/octopusdeploy/schema_action_manual_intervention_test.go index 01e5c0a1d..37399d76f 100644 --- a/octopusdeploy/schema_action_manual_intervention_test.go +++ b/octopusdeploy/schema_action_manual_intervention_test.go @@ -2,20 +2,18 @@ package octopusdeploy import ( "fmt" - "testing" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" ) -func TestAccOctopusDeployManualInterventionAction(t *testing.T) { - resource.Test(t, resource.TestCase{ +func (suite *IntegrationTestSuite) TestAccOctopusDeployManualInterventionAction() { + resource.Test(suite.T(), resource.TestCase{ CheckDestroy: resource.ComposeTestCheckFunc( testAccProjectCheckDestroy, testAccProjectGroupCheckDestroy, testAccLifecycleCheckDestroy, ), - PreCheck: func() { testAccPreCheck(t) }, + PreCheck: func() { testAccPreCheck(suite.T()) }, ProtoV6ProviderFactories: ProtoV6ProviderFactories(), Steps: []resource.TestStep{ { diff --git a/octopusdeploy/schema_action_run_kubectl_script_test.go b/octopusdeploy/schema_action_run_kubectl_script_test.go index 29f468f83..a16e6fa56 100644 --- a/octopusdeploy/schema_action_run_kubectl_script_test.go +++ b/octopusdeploy/schema_action_run_kubectl_script_test.go @@ -2,13 +2,12 @@ package octopusdeploy import ( "fmt" - "testing" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" ) -func TestAccOctopusDeployRunKubectlScriptAction(t *testing.T) { +func (suite *IntegrationTestSuite) TestAccOctopusDeployRunKubectlScriptAction() { + t := suite.T() resource.Test(t, resource.TestCase{ CheckDestroy: resource.ComposeTestCheckFunc( testAccProjectCheckDestroy, diff --git a/octopusdeploy/schema_action_run_script_test.go b/octopusdeploy/schema_action_run_script_test.go index 23fb78a50..925b7cb30 100644 --- a/octopusdeploy/schema_action_run_script_test.go +++ b/octopusdeploy/schema_action_run_script_test.go @@ -33,7 +33,7 @@ func TestExpandRunScriptAction(t *testing.T) { require.NotNil(t, runScriptAction) } -func TestAccRunScriptAction(t *testing.T) { +func (suite *IntegrationTestSuite) TestAccRunScriptAction() { feedLocalName := acctest.RandStringFromCharSet(20, acctest.CharSetAlpha) feedName := acctest.RandStringFromCharSet(20, acctest.CharSetAlpha) feedURI := "http://test.com" @@ -41,7 +41,7 @@ func TestAccRunScriptAction(t *testing.T) { feedUsername := acctest.RandStringFromCharSet(20, acctest.CharSetAlpha) feedPassword := acctest.RandStringFromCharSet(20, acctest.CharSetAlpha) - resource.Test(t, resource.TestCase{ + resource.Test(suite.T(), resource.TestCase{ CheckDestroy: resource.ComposeTestCheckFunc( testAccDeploymentProcessCheckDestroy, testAccProjectCheckDestroy, @@ -49,7 +49,7 @@ func TestAccRunScriptAction(t *testing.T) { testAccEnvironmentCheckDestroy, testAccLifecycleCheckDestroy, ), - PreCheck: func() { testAccPreCheck(t) }, + PreCheck: func() { testAccPreCheck(suite.T()) }, ProtoV6ProviderFactories: ProtoV6ProviderFactories(), Steps: []resource.TestStep{ { diff --git a/octopusdeploy/testing_container_test.go b/octopusdeploy/testing_container_test.go index 8c1bd6397..296b3dac5 100644 --- a/octopusdeploy/testing_container_test.go +++ b/octopusdeploy/testing_container_test.go @@ -6,6 +6,7 @@ import ( "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/client" "github.com/OctopusSolutionsEngineering/OctopusTerraformTestFramework/octoclient" "github.com/OctopusSolutionsEngineering/OctopusTerraformTestFramework/test" + "github.com/stretchr/testify/suite" "github.com/testcontainers/testcontainers-go" "log" "os" @@ -13,52 +14,70 @@ import ( "time" ) -var createSharedContainer = flag.Bool("createSharedContainer", false, "Set to true to run integration tests in containers") +var createSharedContainer = flag.Bool("createSharedContainer", true, "Set to true to run integration tests in containers") +// Note these could and should be removed and replaced by references to the IntegrationTestSuite. +// We haven't done this due to refactoring time. var octoContainer *test.OctopusContainer var octoClient *client.Client -var network testcontainers.Network -var sqlServerContainer *test.MysqlContainer -var err error -func TestMain(m *testing.M) { - flag.Parse() // Parse the flags +type ( + IntegrationTestSuite struct { + suite.Suite + octoContainer *test.OctopusContainer + octoClient *client.Client + network testcontainers.Network + sqlServerContainer *test.MysqlContainer + err error + } +) - if *createSharedContainer { +func TestSdkIntegrationTestSuite(t *testing.T) { + suite.Run(t, &IntegrationTestSuite{}) +} +// SetupSuite implements testify's SetupAllSuite interface and runs at the beginning of the test suite, when suite.Run() is called. +func (suite *IntegrationTestSuite) SetupSuite() { + flag.Parse() // Parse the flags + os.Setenv("TF_ACC", "1") + if *createSharedContainer { testFramework := test.OctopusContainerTest{} - octoContainer, octoClient, sqlServerContainer, network, err = testFramework.ArrangeContainer(m) - if err != nil { - log.Printf("Failed to arrange containers: (%s)", err.Error()) - } - os.Setenv("OCTOPUS_URL", octoContainer.URI) - os.Setenv("OCTOPUS_APIKEY", test.ApiKey) - os.Setenv("TF_ACC", "1") - - code := m.Run() - ctx := context.Background() - - // Waiting for the container logs to clear. - time.Sleep(5000 * time.Millisecond) - err := testFramework.CleanUp(ctx, octoContainer, sqlServerContainer, network) + suite.octoContainer, suite.octoClient, suite.sqlServerContainer, suite.network, suite.err = testFramework.ArrangeContainer() + octoContainer = suite.octoContainer + octoClient = suite.octoClient - if err != nil { - log.Printf("Failed to clean up containers: (%s)", err.Error()) - } - - log.Printf("Exit code: (%d)", code) - os.Exit(code) + os.Setenv("OCTOPUS_URL", suite.octoContainer.URI) + os.Setenv("OCTOPUS_APIKEY", test.ApiKey) } else { if os.Getenv("TF_ACC_LOCAL") != "" { var url = os.Getenv("OCTOPUS_URL") var apikey = os.Getenv("OCTOPUS_APIKEY") - octoClient, err = octoclient.CreateClient(url, "", apikey) - if err != nil { - log.Printf("Failed to create client: (%s)", err.Error()) - panic(m) + suite.octoClient, suite.err = octoclient.CreateClient(url, "", apikey) + if suite.err != nil { + log.Printf("Failed to create client: (%s)", suite.err.Error()) + } + octoContainer = &test.OctopusContainer{ + Container: nil, + URI: url, } } - code := m.Run() - os.Exit(code) } } + +// TearDownSuite implements testify's TearDownAllSuite interface and runs at the end of the suite. +func (suite *IntegrationTestSuite) TearDownSuite() { + // Waiting for the container logs to clear. + time.Sleep(10000 * time.Millisecond) + testFramework := test.OctopusContainerTest{} + ctx := context.Background() + err := testFramework.CleanUp(ctx, suite.octoContainer, suite.sqlServerContainer, suite.network) + + if err != nil { + log.Printf("Failed to clean up containers: (%s)", err.Error()) + } +} + +// TearDownTest implements testify's TearDownTestSuite interface and runs after each suite of tests. +func (suite *IntegrationTestSuite) TearDownTest() { + +} diff --git a/octopusdeploy_framework/artifactory_generic_feed_resource_migration_test.go b/octopusdeploy_framework/artifactory_generic_feed_resource_migration_test.go index dfd30b551..c8e680d7e 100644 --- a/octopusdeploy_framework/artifactory_generic_feed_resource_migration_test.go +++ b/octopusdeploy_framework/artifactory_generic_feed_resource_migration_test.go @@ -11,11 +11,11 @@ import ( "testing" ) -func TestArtifactoryGenericFeedResource_UpgradeFromSDK_ToPluginFramework(t *testing.T) { +func (suite *IntegrationTestSuite) TestArtifactoryGenericFeedResource_UpgradeFromSDK_ToPluginFramework() { // override the path to check for terraformrc file and test against the real 0.21.1 version os.Setenv("TF_CLI_CONFIG_FILE=", "") - resource.Test(t, resource.TestCase{ + resource.Test(suite.T(), resource.TestCase{ CheckDestroy: testArtifactoryGenericFeedDestroy, Steps: []resource.TestStep{ { @@ -40,7 +40,7 @@ func TestArtifactoryGenericFeedResource_UpgradeFromSDK_ToPluginFramework(t *test ProtoV6ProviderFactories: ProtoV6ProviderFactories(), Config: artifactoryGenericUpdatedConfig, Check: resource.ComposeTestCheckFunc( - testArtifactoryGenericFeedUpdated(t), + testArtifactoryGenericFeedUpdated(suite.T()), ), }, }, @@ -90,7 +90,7 @@ func testArtifactoryGenericFeedUpdated(t *testing.T) resource.TestCheckFunc { artifactoryGenericFeed := feed.(*feeds.ArtifactoryGenericFeed) - assert.Regexp(t, "^Feeds\\-\\d+$", artifactoryGenericFeed.GetID(), "Feed ID did not match expected value") + assert.Regexp(t, "^Feeds\\-\\d+$", artifactoryGenericFeed.ID, "Feed ID did not match expected value") assert.Equal(t, "Updated_Artifactory_Generic", artifactoryGenericFeed.Name, "Feed name did not match expected value") assert.Equal(t, "username_Updated", artifactoryGenericFeed.Username, "Feed username did not match expected value") assert.Equal(t, true, artifactoryGenericFeed.Password.HasValue, "Feed password should be set") diff --git a/octopusdeploy_framework/datasource_environments_test.go b/octopusdeploy_framework/datasource_environments_test.go index 3ca2c90ac..648d09337 100644 --- a/octopusdeploy_framework/datasource_environments_test.go +++ b/octopusdeploy_framework/datasource_environments_test.go @@ -2,18 +2,17 @@ package octopusdeploy_framework import ( "fmt" - "testing" - "github.com/hashicorp/terraform-plugin-testing/helper/acctest" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/hashicorp/terraform-plugin-testing/terraform" ) -func TestAccDataSourceEnvironments(t *testing.T) { +func (suite *IntegrationTestSuite) TestAccDataSourceEnvironments() { localName := acctest.RandStringFromCharSet(50, acctest.CharSetAlpha) prefix := fmt.Sprintf("data.octopusdeploy_environments.%s", localName) take := 10 + t := suite.T() resource.Test(t, resource.TestCase{ ProtoV6ProviderFactories: ProtoV6ProviderFactories(), diff --git a/octopusdeploy_framework/datasource_feeds_test.go b/octopusdeploy_framework/datasource_feeds_test.go index ebd7b714c..6644d2f17 100644 --- a/octopusdeploy_framework/datasource_feeds_test.go +++ b/octopusdeploy_framework/datasource_feeds_test.go @@ -2,18 +2,17 @@ package octopusdeploy_framework import ( "fmt" - "testing" - "github.com/hashicorp/terraform-plugin-testing/helper/acctest" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/hashicorp/terraform-plugin-testing/terraform" ) -func TestAccDataSourceFeeds(t *testing.T) { +func (suite *IntegrationTestSuite) TestAccDataSourceFeeds() { localName := acctest.RandStringFromCharSet(50, acctest.CharSetAlpha) prefix := fmt.Sprintf("data.octopusdeploy_feeds.%s", localName) take := 10 + t := suite.T() resource.Test(t, resource.TestCase{ ProtoV6ProviderFactories: ProtoV6ProviderFactories(), diff --git a/octopusdeploy_framework/datasource_project_groups_test.go b/octopusdeploy_framework/datasource_project_groups_test.go index 966048524..235e7afd4 100644 --- a/octopusdeploy_framework/datasource_project_groups_test.go +++ b/octopusdeploy_framework/datasource_project_groups_test.go @@ -3,16 +3,15 @@ package octopusdeploy_framework import ( "fmt" "github.com/hashicorp/terraform-plugin-testing/helper/acctest" - "testing" - "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/hashicorp/terraform-plugin-testing/terraform" ) -func TestAccDataSourceProjectGroups(t *testing.T) { +func (suite *IntegrationTestSuite) TestAccDataSourceProjectGroups() { localName := acctest.RandStringFromCharSet(20, acctest.CharSetAlpha) prefix := fmt.Sprintf("data.octopusdeploy_project_groups.%s", localName) take := 10 + t := suite.T() resource.Test(t, resource.TestCase{ ProtoV6ProviderFactories: ProtoV6ProviderFactories(), diff --git a/octopusdeploy_framework/framework_provider_test.go b/octopusdeploy_framework/framework_provider_test.go index 4a172a7ce..e732a9623 100644 --- a/octopusdeploy_framework/framework_provider_test.go +++ b/octopusdeploy_framework/framework_provider_test.go @@ -42,6 +42,9 @@ func ProtoV6ProviderFactories() map[string]func() (tfprotov6.ProviderServer, err } func TestAccPreCheck(t *testing.T) { + if t.Name() == "TestAccPreCheck" { + t.Skip("Go registers this function as a test, it's intended as validation") + } if v := os.Getenv("OCTOPUS_URL"); isEmpty(v) { t.Fatal("OCTOPUS_URL must be set for acceptance tests") } diff --git a/octopusdeploy_framework/github_repository_feed_resource_migration_test.go b/octopusdeploy_framework/github_repository_feed_resource_migration_test.go index caf5e5dc6..40a493999 100644 --- a/octopusdeploy_framework/github_repository_feed_resource_migration_test.go +++ b/octopusdeploy_framework/github_repository_feed_resource_migration_test.go @@ -11,9 +11,10 @@ import ( "testing" ) -func TestGitHubFeed_UpgradeFromSDK_ToPluginFramework(t *testing.T) { +func (suite *IntegrationTestSuite) TestGitHubFeed_UpgradeFromSDK_ToPluginFramework() { // override the path to check for terraformrc file and test against the real 0.21.1 version os.Setenv("TF_CLI_CONFIG_FILE=", "") + t := suite.T() resource.Test(t, resource.TestCase{ CheckDestroy: testGitHubFeedDestroy, @@ -90,7 +91,7 @@ func testGitHubFeedUpdated(t *testing.T) resource.TestCheckFunc { githubRepositoryFeed := feed.(*feeds.GitHubRepositoryFeed) - assert.Regexp(t, "^Feeds\\-\\d+$", githubRepositoryFeed.GetID(), "Feed ID did not match expected value") + assert.Regexp(t, "^Feeds\\-\\d+$", githubRepositoryFeed.ID, "Feed ID did not match expected value") assert.Equal(t, "Updated Test GitHub Feed", githubRepositoryFeed.Name, "Feed name did not match expected value") assert.Equal(t, "username_Updated", githubRepositoryFeed.Username, "Feed username did not match expected value") assert.Equal(t, true, githubRepositoryFeed.Password.HasValue, "Feed password should be set") diff --git a/octopusdeploy_framework/helm_feed_resource_migration_test.go b/octopusdeploy_framework/helm_feed_resource_migration_test.go index 785f3ded4..53838944f 100644 --- a/octopusdeploy_framework/helm_feed_resource_migration_test.go +++ b/octopusdeploy_framework/helm_feed_resource_migration_test.go @@ -11,9 +11,10 @@ import ( "testing" ) -func TestHelmFeedResource_UpgradeFromSDK_ToPluginFramework(t *testing.T) { +func (suite *IntegrationTestSuite) TestHelmFeedResource_UpgradeFromSDK_ToPluginFramework() { // override the path to check for terraformrc file and test against the real 0.21.1 version os.Setenv("TF_CLI_CONFIG_FILE=", "") + t := suite.T() resource.Test(t, resource.TestCase{ CheckDestroy: testHelmFeedDestroy, @@ -86,7 +87,7 @@ func testHelmFeedUpdated(t *testing.T) resource.TestCheckFunc { helmFeed := feed.(*feeds.HelmFeed) - assert.Regexp(t, "^Feeds\\-\\d+$", helmFeed.GetID(), "Feed ID did not match expected value") + assert.Regexp(t, "^Feeds\\-\\d+$", helmFeed.ID, "Feed ID did not match expected value") assert.Equal(t, "Updated_Helm", helmFeed.Name, "Feed name did not match expected value") assert.Equal(t, "username_Updated", helmFeed.Username, "Feed username did not match expected value") assert.Equal(t, true, helmFeed.Password.HasValue, "Feed password should be set") diff --git a/octopusdeploy_framework/maven_feed_resource_migration_test.go b/octopusdeploy_framework/maven_feed_resource_migration_test.go index 339d54588..87d70e397 100644 --- a/octopusdeploy_framework/maven_feed_resource_migration_test.go +++ b/octopusdeploy_framework/maven_feed_resource_migration_test.go @@ -11,9 +11,10 @@ import ( "testing" ) -func TestMavenResource_UpgradeFromSDK_ToPluginFramework(t *testing.T) { +func (suite *IntegrationTestSuite) TestMavenResource_UpgradeFromSDK_ToPluginFramework() { // override the path to check for terraformrc file and test against the real 0.21.1 version os.Setenv("TF_CLI_CONFIG_FILE=", "") + t := suite.T() resource.Test(t, resource.TestCase{ CheckDestroy: testFeedDestroy, @@ -90,7 +91,7 @@ func testFeedUpdated(t *testing.T) resource.TestCheckFunc { mavenFeed := feed.(*feeds.MavenFeed) - assert.Regexp(t, "^Feeds\\-\\d+$", mavenFeed.GetID(), "Feed ID did not match expected value") + assert.Regexp(t, "^Feeds\\-\\d+$", mavenFeed.ID, "Feed ID did not match expected value") assert.Equal(t, "Updated_Maven", mavenFeed.Name, "Feed name did not match expected value") assert.Equal(t, "username_Updated", mavenFeed.Username, "Feed username did not match expected value") assert.Equal(t, true, mavenFeed.Password.HasValue, "Feed password should be set") diff --git a/octopusdeploy_framework/nuget_feed_resource_migration_test.go b/octopusdeploy_framework/nuget_feed_resource_migration_test.go index 4216d1b72..885f60799 100644 --- a/octopusdeploy_framework/nuget_feed_resource_migration_test.go +++ b/octopusdeploy_framework/nuget_feed_resource_migration_test.go @@ -11,9 +11,10 @@ import ( "testing" ) -func TestNugetFeed_UpgradeFromSDK_ToPluginFramework(t *testing.T) { +func (suite *IntegrationTestSuite) TestNugetFeed_UpgradeFromSDK_ToPluginFramework() { // override the path to check for terraformrc file and test against the real 0.21.1 version os.Setenv("TF_CLI_CONFIG_FILE=", "") + t := suite.T() resource.Test(t, resource.TestCase{ CheckDestroy: testNugetFeedDestroy, @@ -92,7 +93,7 @@ func testNugetFeedUpdated(t *testing.T) resource.TestCheckFunc { nugetFeed := feed.(*feeds.NuGetFeed) - assert.Regexp(t, "^Feeds\\-\\d+$", nugetFeed.GetID(), "Feed ID did not match expected value") + assert.Regexp(t, "^Feeds\\-\\d+$", nugetFeed.ID, "Feed ID did not match expected value") assert.Equal(t, "Updated Nuget", nugetFeed.Name, "Feed name did not match expected value") assert.Equal(t, "username_Updated", nugetFeed.Username, "Feed username did not match expected value") assert.Equal(t, true, nugetFeed.Password.HasValue, "Feed password should be set") diff --git a/octopusdeploy_framework/resource_artifactory_generic_feed_test.go b/octopusdeploy_framework/resource_artifactory_generic_feed_test.go index 4c099c7aa..45d401a4a 100644 --- a/octopusdeploy_framework/resource_artifactory_generic_feed_test.go +++ b/octopusdeploy_framework/resource_artifactory_generic_feed_test.go @@ -5,10 +5,9 @@ import ( "github.com/hashicorp/terraform-plugin-testing/helper/acctest" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/hashicorp/terraform-plugin-testing/terraform" - "testing" ) -func TestAccOctopusDeployArtifactoryGenericFeed(t *testing.T) { +func (suite *IntegrationTestSuite) TestAccOctopusDeployArtifactoryGenericFeed() { localName := acctest.RandStringFromCharSet(20, acctest.CharSetAlpha) prefix := "octopusdeploy_artifactory_generic_feed." + localName @@ -18,6 +17,7 @@ func TestAccOctopusDeployArtifactoryGenericFeed(t *testing.T) { username := acctest.RandStringFromCharSet(20, acctest.CharSetAlpha) repository := acctest.RandStringFromCharSet(20, acctest.CharSetAlpha) layoutRegex := acctest.RandStringFromCharSet(20, acctest.CharSetAlpha) + t := suite.T() resource.Test(t, resource.TestCase{ CheckDestroy: testArtifactoryGenericFeedCheckDestroy, diff --git a/octopusdeploy_framework/resource_aws_elastic_container_registry_test.go b/octopusdeploy_framework/resource_aws_elastic_container_registry_test.go index 433b2cd2b..312c3e4a1 100644 --- a/octopusdeploy_framework/resource_aws_elastic_container_registry_test.go +++ b/octopusdeploy_framework/resource_aws_elastic_container_registry_test.go @@ -6,11 +6,11 @@ import ( "github.com/OctopusSolutionsEngineering/OctopusTerraformTestFramework/test" "os" "path/filepath" - "testing" ) // TestEcrFeedResource verifies that a ecr feed can be reimported with the correct settings -func TestEcrFeedResource(t *testing.T) { +func (suite *IntegrationTestSuite) TestEcrFeedResource() { + t := suite.T() if os.Getenv("ECR_ACCESS_KEY") == "" { t.Fatal("The ECR_ACCESS_KEY environment variable must be set a valid AWS access key") } diff --git a/octopusdeploy_framework/resource_environment_migration_test.go b/octopusdeploy_framework/resource_environment_migration_test.go index 79e3e84f2..41ea24e98 100644 --- a/octopusdeploy_framework/resource_environment_migration_test.go +++ b/octopusdeploy_framework/resource_environment_migration_test.go @@ -11,12 +11,12 @@ import ( "testing" ) -func TestEnvironmentResource_UpgradeFromSDK_ToPluginFramework(t *testing.T) { +func (suite *IntegrationTestSuite) TestEnvironmentResource_UpgradeFromSDK_ToPluginFramework() { // override the path to check for terraformrc file and test against the real 0.21.1 version os.Setenv("TF_CLI_CONFIG_FILE=", "") name := acctest.RandStringFromCharSet(20, acctest.CharSetAlpha) - resource.Test(t, resource.TestCase{ + resource.Test(suite.T(), resource.TestCase{ CheckDestroy: testEnvironmentDestroy, Steps: []resource.TestStep{ { @@ -41,7 +41,7 @@ func TestEnvironmentResource_UpgradeFromSDK_ToPluginFramework(t *testing.T) { ProtoV6ProviderFactories: ProtoV6ProviderFactories(), Config: updateEnvironmentConfig(name), Check: resource.ComposeTestCheckFunc( - testEnvironment(t, name), + testEnvironment(suite.T(), name), ), }, }, diff --git a/octopusdeploy_framework/resource_environment_test.go b/octopusdeploy_framework/resource_environment_test.go index 5b2bbcd05..621955d9c 100644 --- a/octopusdeploy_framework/resource_environment_test.go +++ b/octopusdeploy_framework/resource_environment_test.go @@ -2,20 +2,18 @@ package octopusdeploy_framework import ( "fmt" - "path/filepath" - "strconv" - "testing" - "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/environments" "github.com/OctopusSolutionsEngineering/OctopusTerraformTestFramework/octoclient" "github.com/OctopusSolutionsEngineering/OctopusTerraformTestFramework/test" + "path/filepath" + "strconv" "github.com/hashicorp/terraform-plugin-testing/helper/acctest" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/hashicorp/terraform-plugin-testing/terraform" ) -func TestAccOctopusDeployEnvironmentBasic(t *testing.T) { +func (suite *IntegrationTestSuite) TestAccOctopusDeployEnvironmentBasic() { localName := acctest.RandStringFromCharSet(20, acctest.CharSetAlpha) prefix := "octopusdeploy_environment." + localName @@ -24,6 +22,7 @@ func TestAccOctopusDeployEnvironmentBasic(t *testing.T) { name := acctest.RandStringFromCharSet(20, acctest.CharSetAlpha) sortOrder := acctest.RandIntRange(0, 10) useGuidedFailure := false + t := suite.T() resource.Test(t, resource.TestCase{ CheckDestroy: testAccEnvironmentCheckDestroy, @@ -45,7 +44,7 @@ func TestAccOctopusDeployEnvironmentBasic(t *testing.T) { }) } -func TestAccOctopusDeployEnvironmentMinimum(t *testing.T) { +func (suite *IntegrationTestSuite) TestAccOctopusDeployEnvironmentMinimum() { allowDynamicInfrastructure := false description := acctest.RandStringFromCharSet(20, acctest.CharSetAlpha) localName := acctest.RandStringFromCharSet(20, acctest.CharSetAlpha) @@ -53,6 +52,7 @@ func TestAccOctopusDeployEnvironmentMinimum(t *testing.T) { name := acctest.RandStringFromCharSet(20, acctest.CharSetAlpha) sortOrder := acctest.RandIntRange(0, 10) useGuidedFailure := false + t := suite.T() resource.Test(t, resource.TestCase{ CheckDestroy: testAccEnvironmentCheckDestroy, @@ -106,8 +106,9 @@ func testAccEnvironmentCheckDestroy(s *terraform.State) error { } // TestEnvironmentResource verifies that an environment can be reimported with the correct settings -func TestEnvironmentResource(t *testing.T) { +func (suite *IntegrationTestSuite) TestEnvironmentResource() { testFramework := test.OctopusContainerTest{} + t := suite.T() newSpaceId, err := testFramework.Act(t, octoContainer, "../terraform", "16-environment", []string{}) diff --git a/octopusdeploy_framework/resource_git_credential_test.go b/octopusdeploy_framework/resource_git_credential_test.go index 92e0f6c82..06d8ceb17 100644 --- a/octopusdeploy_framework/resource_git_credential_test.go +++ b/octopusdeploy_framework/resource_git_credential_test.go @@ -6,15 +6,15 @@ import ( "github.com/hashicorp/terraform-plugin-testing/helper/acctest" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "path/filepath" - "testing" ) -func TestGitCredentialBasic(t *testing.T) { +func (suite *IntegrationTestSuite) TestGitCredentialBasic() { localName := acctest.RandStringFromCharSet(20, acctest.CharSetAlpha) resourceName := "octopusdeploy_git_credential." + localName name := acctest.RandStringFromCharSet(20, acctest.CharSetAlpha) description := acctest.RandStringFromCharSet(20, acctest.CharSetAlpha) + t := suite.T() resource.Test(t, resource.TestCase{ PreCheck: func() { TestAccPreCheck(t) }, ProtoV6ProviderFactories: ProtoV6ProviderFactories(), @@ -43,8 +43,9 @@ func testGitCredential(localName string, name string, description string) string } // TestGitCredentialsResource verifies that a git credential can be reimported with the correct settings -func TestGitCredentialsResource(t *testing.T) { +func (suite *IntegrationTestSuite) TestGitCredentialsResource() { testFramework := test.OctopusContainerTest{} + t := suite.T() newSpaceId, err := testFramework.Act(t, octoContainer, "../terraform", "22-gitcredentialtest", []string{}) diff --git a/octopusdeploy_framework/resource_github_repository_feed_test.go b/octopusdeploy_framework/resource_github_repository_feed_test.go index 5d26aab8d..e0c8664a1 100644 --- a/octopusdeploy_framework/resource_github_repository_feed_test.go +++ b/octopusdeploy_framework/resource_github_repository_feed_test.go @@ -10,10 +10,9 @@ import ( "github.com/hashicorp/terraform-plugin-testing/terraform" "path/filepath" "strconv" - "testing" ) -func TestGitHubRepositoryFeed(t *testing.T) { +func (suite *IntegrationTestSuite) TestGitHubRepositoryFeed() { localName := acctest.RandStringFromCharSet(20, acctest.CharSetAlpha) prefix := "octopusdeploy_github_repository_feed." + localName @@ -23,6 +22,7 @@ func TestGitHubRepositoryFeed(t *testing.T) { name := acctest.RandStringFromCharSet(20, acctest.CharSetAlpha) password := acctest.RandStringFromCharSet(20, acctest.CharSetAlpha) username := acctest.RandStringFromCharSet(20, acctest.CharSetAlpha) + t := suite.T() resource.Test(t, resource.TestCase{ CheckDestroy: testGitHubRepositoryFeedCheckDestroy, @@ -83,8 +83,9 @@ func testGitHubRepositoryFeedCheckDestroy(s *terraform.State) error { } // TestGithubFeedResource verifies that a nuget feed can be reimported with the correct settings -func TestGithubFeedResource(t *testing.T) { +func (suite *IntegrationTestSuite) TestGithubFeedResource() { testFramework := test.OctopusContainerTest{} + t := suite.T() newSpaceId, err := testFramework.Act(t, octoContainer, "../terraform", "44-githubfeed", []string{}) diff --git a/octopusdeploy_framework/resource_helm_feed_test.go b/octopusdeploy_framework/resource_helm_feed_test.go index f34a0ae18..6012177ea 100644 --- a/octopusdeploy_framework/resource_helm_feed_test.go +++ b/octopusdeploy_framework/resource_helm_feed_test.go @@ -9,10 +9,9 @@ import ( "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/hashicorp/terraform-plugin-testing/terraform" "path/filepath" - "testing" ) -func TestAccOctopusDeployHelmFeed(t *testing.T) { +func (suite *IntegrationTestSuite) TestAccOctopusDeployHelmFeed() { localName := acctest.RandStringFromCharSet(20, acctest.CharSetAlpha) prefix := "octopusdeploy_helm_feed." + localName @@ -22,6 +21,7 @@ func TestAccOctopusDeployHelmFeed(t *testing.T) { username := acctest.RandStringFromCharSet(20, acctest.CharSetAlpha) updatedName := acctest.RandStringFromCharSet(20, acctest.CharSetAlpha) + t := suite.T() resource.Test(t, resource.TestCase{ CheckDestroy: testHelmFeedCheckDestroy, @@ -88,8 +88,9 @@ func testHelmFeedCheckDestroy(s *terraform.State) error { } // TestHelmFeedResource verifies that a helm feed can be reimported with the correct settings -func TestHelmFeedResource(t *testing.T) { +func (suite *IntegrationTestSuite) TestHelmFeedResource() { testFramework := test.OctopusContainerTest{} + t := suite.T() newSpaceId, err := testFramework.Act(t, octoContainer, "../terraform", "10-helmfeed", []string{}) diff --git a/octopusdeploy_framework/resource_library_variable_set_test.go b/octopusdeploy_framework/resource_library_variable_set_test.go index b9e2236d4..937851883 100644 --- a/octopusdeploy_framework/resource_library_variable_set_test.go +++ b/octopusdeploy_framework/resource_library_variable_set_test.go @@ -2,17 +2,16 @@ package octopusdeploy_framework import ( "fmt" + "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/client" "github.com/hashicorp/terraform-plugin-testing/helper/acctest" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/hashicorp/terraform-plugin-testing/terraform" - "testing" - - "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/client" ) -func TestAccOctopusDeployLibraryVariableSetBasic(t *testing.T) { +func (suite *IntegrationTestSuite) TestAccOctopusDeployLibraryVariableSetBasic() { localName := acctest.RandStringFromCharSet(20, acctest.CharSetAlpha) prefix := "octopusdeploy_library_variable_set." + localName + t := suite.T() name := acctest.RandStringFromCharSet(20, acctest.CharSetAlpha) @@ -32,16 +31,16 @@ func TestAccOctopusDeployLibraryVariableSetBasic(t *testing.T) { }) } -func TestAccOctopusDeployLibraryVariableSetComplex(t *testing.T) { +func (suite *IntegrationTestSuite) TestAccOctopusDeployLibraryVariableSetComplex() { localName := acctest.RandStringFromCharSet(20, acctest.CharSetAlpha) prefix := "octopusdeploy_library_variable_set." + localName name := acctest.RandStringFromCharSet(20, acctest.CharSetAlpha) description := acctest.RandStringFromCharSet(20, acctest.CharSetAlpha) - resource.Test(t, resource.TestCase{ + resource.Test(suite.T(), resource.TestCase{ CheckDestroy: testLibraryVariableSetDestroy, - PreCheck: func() { TestAccPreCheck(t) }, + PreCheck: func() { TestAccPreCheck(suite.T()) }, ProtoV6ProviderFactories: ProtoV6ProviderFactories(), Steps: []resource.TestStep{ { @@ -73,7 +72,7 @@ func TestAccOctopusDeployLibraryVariableSetComplex(t *testing.T) { }) } -func TestAccOctopusDeployLibraryVariableSetWithUpdate(t *testing.T) { +func (suite *IntegrationTestSuite) TestAccOctopusDeployLibraryVariableSetWithUpdate() { localName := acctest.RandStringFromCharSet(20, acctest.CharSetAlpha) prefix := "octopusdeploy_library_variable_set." + localName @@ -83,9 +82,9 @@ func TestAccOctopusDeployLibraryVariableSetWithUpdate(t *testing.T) { description := acctest.RandStringFromCharSet(20, acctest.CharSetAlpha) name := acctest.RandStringFromCharSet(20, acctest.CharSetAlpha) - resource.Test(t, resource.TestCase{ + resource.Test(suite.T(), resource.TestCase{ CheckDestroy: testLibraryVariableSetDestroy, - PreCheck: func() { TestAccPreCheck(t) }, + PreCheck: func() { TestAccPreCheck(suite.T()) }, ProtoV6ProviderFactories: ProtoV6ProviderFactories(), Steps: []resource.TestStep{ // create variable set with no description diff --git a/octopusdeploy_framework/resource_lifecycle_test.go b/octopusdeploy_framework/resource_lifecycle_test.go index 639fc6a93..bcad1b5cf 100644 --- a/octopusdeploy_framework/resource_lifecycle_test.go +++ b/octopusdeploy_framework/resource_lifecycle_test.go @@ -22,13 +22,14 @@ func TestExpandLifecycleWithNil(t *testing.T) { require.Nil(t, lifecycle) } -func TestExpandLifecycle(t *testing.T) { +func (suite *IntegrationTestSuite) TestExpandLifecycle() { description := "test-description" name := "test-name" spaceID := "test-space-id" Id := "test-id" releaseRetention := core.NewRetentionPeriod(0, "Days", true) tentacleRetention := core.NewRetentionPeriod(2, "Items", false) + t := suite.T() data := &lifecycleTypeResourceModel{ ID: types.StringValue(Id), @@ -94,8 +95,9 @@ func TestExpandPhasesWithUnknownInput(t *testing.T) { require.Nil(t, phases) } -func TestExpandAndFlattenPhasesWithSensibleDefaults(t *testing.T) { +func (suite *IntegrationTestSuite) TestExpandAndFlattenPhasesWithSensibleDefaults() { phase := createTestPhase("TestPhase", []string{"AutoTarget1", "AutoTarget2"}, true, 5) + t := suite.T() flattenedPhases := flattenPhases([]*lifecycles.Phase{phase}) require.NotNil(t, flattenedPhases) @@ -115,9 +117,10 @@ func TestExpandAndFlattenPhasesWithSensibleDefaults(t *testing.T) { require.Equal(t, phase.TentacleRetentionPolicy, expandedPhase.TentacleRetentionPolicy) } -func TestExpandAndFlattenMultiplePhasesWithSensibleDefaults(t *testing.T) { +func (suite *IntegrationTestSuite) TestExpandAndFlattenMultiplePhasesWithSensibleDefaults() { phase1 := createTestPhase("Phase1", []string{"AutoTarget1", "AutoTarget2"}, true, 5) phase2 := createTestPhase("Phase2", []string{"AutoTarget3", "AutoTarget4"}, false, 3) + t := suite.T() flattenedPhases := flattenPhases([]*lifecycles.Phase{phase1, phase2}) require.NotNil(t, flattenedPhases) @@ -157,11 +160,12 @@ func createTestPhase(name string, autoTargets []string, isOptional bool, minEnvs //Integration test under here -func TestAccLifecycleBasic(t *testing.T) { +func (suite *IntegrationTestSuite) TestAccLifecycleBasic() { localName := acctest.RandStringFromCharSet(20, acctest.CharSetAlpha) resourceName := "octopusdeploy_lifecycle." + localName name := acctest.RandStringFromCharSet(20, acctest.CharSetAlpha) + t := suite.T() resource.Test(t, resource.TestCase{ CheckDestroy: testAccLifecycleCheckDestroy, @@ -189,11 +193,12 @@ func TestAccLifecycleBasic(t *testing.T) { }) } -func TestAccLifecycleWithUpdate(t *testing.T) { +func (suite *IntegrationTestSuite) TestAccLifecycleWithUpdate() { localName := acctest.RandStringFromCharSet(20, acctest.CharSetAlpha) resourceName := "octopusdeploy_lifecycle." + localName description := acctest.RandStringFromCharSet(20, acctest.CharSetAlpha) name := acctest.RandStringFromCharSet(20, acctest.CharSetAlpha) + t := suite.T() resource.Test(t, resource.TestCase{ CheckDestroy: testAccLifecycleCheckDestroy, @@ -279,11 +284,12 @@ func TestAccLifecycleWithUpdate(t *testing.T) { }) } -func TestAccLifecycleComplex(t *testing.T) { +func (suite *IntegrationTestSuite) TestAccLifecycleComplex() { localName := acctest.RandStringFromCharSet(20, acctest.CharSetAlpha) resourceName := "octopusdeploy_lifecycle." + localName name := acctest.RandStringFromCharSet(20, acctest.CharSetAlpha) + t := suite.T() resource.Test(t, resource.TestCase{ CheckDestroy: testAccLifecycleCheckDestroy, @@ -441,8 +447,9 @@ func testAccLifecycleCheckDestroy(s *terraform.State) error { } // TestLifecycleResource verifies that a lifecycle can be reimported with the correct settings -func TestLifecycleResource(t *testing.T) { +func (suite *IntegrationTestSuite) TestLifecycleResource() { testFramework := test.OctopusContainerTest{} + t := suite.T() newSpaceId, err := testFramework.Act(t, octoContainer, "../terraform", "17-lifecycle", []string{}) if err != nil { diff --git a/octopusdeploy_framework/resource_maven_feed_test.go b/octopusdeploy_framework/resource_maven_feed_test.go index b0b9d504d..b27771706 100644 --- a/octopusdeploy_framework/resource_maven_feed_test.go +++ b/octopusdeploy_framework/resource_maven_feed_test.go @@ -10,10 +10,9 @@ import ( "github.com/hashicorp/terraform-plugin-testing/terraform" "path/filepath" "strconv" - "testing" ) -func TestAccOctopusDeployMavenFeed(t *testing.T) { +func (suite *IntegrationTestSuite) TestAccOctopusDeployMavenFeed() { localName := acctest.RandStringFromCharSet(20, acctest.CharSetAlpha) prefix := "octopusdeploy_maven_feed." + localName @@ -23,6 +22,7 @@ func TestAccOctopusDeployMavenFeed(t *testing.T) { name := acctest.RandStringFromCharSet(20, acctest.CharSetAlpha) password := acctest.RandStringFromCharSet(20, acctest.CharSetAlpha) username := acctest.RandStringFromCharSet(20, acctest.CharSetAlpha) + t := suite.T() resource.Test(t, resource.TestCase{ CheckDestroy: testMavenFeedCheckDestroy, @@ -83,8 +83,9 @@ func testMavenFeedCheckDestroy(s *terraform.State) error { } // TestMavenFeedResource verifies that a maven feed can be reimported with the correct settings -func TestMavenFeedResource(t *testing.T) { +func (suite *IntegrationTestSuite) TestMavenFeedResource() { testFramework := test.OctopusContainerTest{} + t := suite.T() newSpaceId, err := testFramework.Act(t, octoContainer, "../terraform", "13-mavenfeed", []string{}) if err != nil { diff --git a/octopusdeploy_framework/resource_nuget_feed_test.go b/octopusdeploy_framework/resource_nuget_feed_test.go index f5d327612..f077f71d7 100644 --- a/octopusdeploy_framework/resource_nuget_feed_test.go +++ b/octopusdeploy_framework/resource_nuget_feed_test.go @@ -10,12 +10,12 @@ import ( "github.com/hashicorp/terraform-plugin-testing/terraform" "path/filepath" "strconv" - "testing" ) -func TestAccOctopusDeployNuGetFeedBasic(t *testing.T) { +func (suite *IntegrationTestSuite) TestAccOctopusDeployNuGetFeedBasic() { localName := acctest.RandStringFromCharSet(20, acctest.CharSetAlpha) prefix := "octopusdeploy_nuget_feed." + localName + t := suite.T() name := acctest.RandStringFromCharSet(20, acctest.CharSetAlpha) feedURI := "http://test.com" @@ -93,8 +93,9 @@ func testOctopusDeployNuGetFeedDestroy(s *terraform.State) error { } // TestNugetFeedResource verifies that a nuget feed can be reimported with the correct settings -func TestNugetFeedResource(t *testing.T) { +func (suite *IntegrationTestSuite) TestNugetFeedResource() { testFramework := test.OctopusContainerTest{} + t := suite.T() newSpaceId, err := testFramework.Act(t, octoContainer, "../terraform", "14-nugetfeed", []string{}) if err != nil { diff --git a/octopusdeploy_framework/resource_project_group_test.go b/octopusdeploy_framework/resource_project_group_test.go index 75b7bbcdd..2223d9d7c 100644 --- a/octopusdeploy_framework/resource_project_group_test.go +++ b/octopusdeploy_framework/resource_project_group_test.go @@ -5,12 +5,12 @@ import ( "github.com/OctopusSolutionsEngineering/OctopusTerraformTestFramework/octoclient" "github.com/OctopusSolutionsEngineering/OctopusTerraformTestFramework/test" "path/filepath" - "testing" ) // TestProjectGroupResource verifies that a project group can be reimported with the correct settings -func TestProjectGroupResource(t *testing.T) { +func (suite *IntegrationTestSuite) TestProjectGroupResource() { testFramework := test.OctopusContainerTest{} + t := suite.T() newSpaceId, err := testFramework.Act(t, octoContainer, "../terraform", "2-projectgroup", []string{}) if err != nil { diff --git a/octopusdeploy_framework/resource_tenant_common_variable_test.go b/octopusdeploy_framework/resource_tenant_common_variable_test.go index 97bd904fc..9ed9b50af 100644 --- a/octopusdeploy_framework/resource_tenant_common_variable_test.go +++ b/octopusdeploy_framework/resource_tenant_common_variable_test.go @@ -2,20 +2,18 @@ package octopusdeploy_framework import ( "fmt" + localtest "github.com/OctopusDeploy/terraform-provider-octopusdeploy/internal/test" "github.com/OctopusSolutionsEngineering/OctopusTerraformTestFramework/octoclient" "github.com/OctopusSolutionsEngineering/OctopusTerraformTestFramework/test" "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" - - localtest "github.com/OctopusDeploy/terraform-provider-octopusdeploy/internal/test" ) -func TestAccTenantCommonVariableBasic(t *testing.T) { - SkipCI(t, "project_environment have been refactor [deprecated] - will enable this test later after Ben fix") - //SkipCI(t, "A managed resource \"octopusdeploy_project_group\" \"ewtxiwplhaenzmhpaqyx\" has\n not been declared in the root module.") +func (suite *IntegrationTestSuite) TestAccTenantCommonVariableBasic() { + t := suite.T() + SkipCI(t, "A managed resource \"octopusdeploy_project_group\" \"ewtxiwplhaenzmhpaqyx\" has\n not been declared in the root module.") lifecycleLocalName := acctest.RandStringFromCharSet(20, acctest.CharSetAlpha) lifecycleName := acctest.RandStringFromCharSet(20, acctest.CharSetAlpha) projectGroupLocalName := acctest.RandStringFromCharSet(20, acctest.CharSetAlpha) @@ -64,8 +62,8 @@ func testAccTenantCommonVariableBasic(lifecycleLocalName string, lifecycleName s description := acctest.RandStringFromCharSet(20, acctest.CharSetAlpha) sortOrder := acctest.RandIntRange(0, 10) useGuidedFailure := false - projectGroup.LocalName = projectGroupLocalName - var tfConfig = fmt.Sprintf(testAccLifecycle(lifecycleLocalName, lifecycleName)+"\n"+ + + return fmt.Sprintf(testAccLifecycle(lifecycleLocalName, lifecycleName)+"\n"+ localtest.ProjectGroupConfiguration(projectGroup)+"\n"+ testAccEnvironment(environmentLocalName, environmentName, description, allowDynamicInfrastructure, sortOrder, useGuidedFailure)+"\n"+` resource "octopusdeploy_library_variable_set" "test-library-variable-set" { @@ -106,7 +104,6 @@ func testAccTenantCommonVariableBasic(lifecycleLocalName string, lifecycleName s tenant_id = octopusdeploy_tenant.%s.id value = "%s" }`, projectLocalName, lifecycleLocalName, projectName, projectGroupLocalName, tenantLocalName, tenantName, projectLocalName, environmentLocalName, localName, tenantLocalName, value) - return tfConfig } func testTenantCommonVariableExists(resourceName string) resource.TestCheckFunc { @@ -185,8 +182,9 @@ func testAccTenantCommonVariableCheckDestroy(s *terraform.State) error { } // TestTenantVariablesResource verifies that a tenant variables can be reimported with the correct settings -func TestTenantVariablesResource(t *testing.T) { +func (suite *IntegrationTestSuite) TestTenantVariablesResource() { testFramework := test.OctopusContainerTest{} + t := suite.T() newSpaceId, err := testFramework.Act(t, octoContainer, "../terraform", "26-tenant_variables", []string{}) if err != nil { diff --git a/octopusdeploy_framework/resource_tenant_project_migration_test.go b/octopusdeploy_framework/resource_tenant_project_migration_test.go index f1f054bd5..65b618226 100644 --- a/octopusdeploy_framework/resource_tenant_project_migration_test.go +++ b/octopusdeploy_framework/resource_tenant_project_migration_test.go @@ -11,9 +11,10 @@ import ( "testing" ) -func TestTenantProjectResource_UpgradeFromSDK_ToPluginFramework(t *testing.T) { +func (suite *IntegrationTestSuite) TestTenantProjectResource_UpgradeFromSDK_ToPluginFramework() { // override the path to check for terraformrc file and test against the real 0.21.1 version os.Setenv("TF_CLI_CONFIG_FILE=", "") + t := suite.T() name := acctest.RandStringFromCharSet(20, acctest.CharSetAlpha) resource.Test(t, resource.TestCase{ diff --git a/octopusdeploy_framework/resource_tenant_project_variable_test.go b/octopusdeploy_framework/resource_tenant_project_variable_test.go index 69c740adb..0f256a52d 100644 --- a/octopusdeploy_framework/resource_tenant_project_variable_test.go +++ b/octopusdeploy_framework/resource_tenant_project_variable_test.go @@ -6,11 +6,10 @@ import ( "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/hashicorp/terraform-plugin-testing/terraform" "strings" - "testing" ) -func TestAccTenantProjectVariableBasic(t *testing.T) { - SkipCI(t, "project_environment have been refactor [deprecated] - will enable this test later after Ben fix") +func (suite *IntegrationTestSuite) TestAccTenantProjectVariableBasic() { + SkipCI(suite.T(), "project_environment have been refactor [deprecated] - will enable this test later after Ben fix") lifecycleLocalName := acctest.RandStringFromCharSet(20, acctest.CharSetAlpha) lifecycleName := acctest.RandStringFromCharSet(20, acctest.CharSetAlpha) projectGroupLocalName := acctest.RandStringFromCharSet(20, acctest.CharSetAlpha) @@ -35,9 +34,9 @@ func TestAccTenantProjectVariableBasic(t *testing.T) { newValue := acctest.RandStringFromCharSet(20, acctest.CharSetAlpha) - resource.Test(t, resource.TestCase{ + resource.Test(suite.T(), resource.TestCase{ CheckDestroy: testAccTenantProjectVariableCheckDestroy, - PreCheck: func() { TestAccPreCheck(t) }, + PreCheck: func() { TestAccPreCheck(suite.T()) }, ProtoV6ProviderFactories: ProtoV6ProviderFactories(), Steps: []resource.TestStep{ { @@ -68,7 +67,7 @@ func testAccTenantProjectVariable(lifecycleLocalName string, lifecycleName strin sortOrder := acctest.RandIntRange(0, 10) useGuidedFailure := false - var tfconfig = testAccLifecycle(lifecycleLocalName, lifecycleName) + "\n" + + return testAccLifecycle(lifecycleLocalName, lifecycleName) + "\n" + testAccProjectGroup(projectGroupLocalName, projectGroupName) + "\n" + testAccProjectWithTemplate(projectLocalName, projectName, lifecycleLocalName, projectGroupLocalName) + "\n" + testAccEnvironment(primaryEnvironmentLocalName, primaryEnvironmentName, description, allowDynamicInfrastructure, sortOrder, useGuidedFailure) + "\n" + @@ -76,30 +75,6 @@ func testAccTenantProjectVariable(lifecycleLocalName string, lifecycleName strin testAccTenantWithProjectEnvironment(tenantLocalName, tenantName, projectLocalName, primaryEnvironmentLocalName, secondaryEnvironmentLocalName) + "\n" + testTenantProjectVariable(primaryLocalName, primaryEnvironmentLocalName, projectLocalName, tenantLocalName, projectLocalName, primaryValue) + "\n" + testTenantProjectVariable(secondaryLocalName, secondaryEnvironmentLocalName, projectLocalName, tenantLocalName, projectLocalName, secondaryValue) - return tfconfig -} - -func testAccProjectWithTemplate(localName string, name string, lifecycleLocalName string, projectGroupLocalName string) string { - return fmt.Sprintf(`resource "octopusdeploy_project" "%s" { - lifecycle_id = octopusdeploy_lifecycle.%s.id - name = "%s" - project_group_id = octopusdeploy_project_group.%s.id - - template { - name = "project variable template name" - label = "project variable template label" - - display_settings = { - "Octopus.ControlType" = "Sensitive" - } - } - }`, localName, lifecycleLocalName, name, projectGroupLocalName) -} - -func testAccProjectGroup(localName string, name string) string { - return fmt.Sprintf(`resource "octopusdeploy_project_group" "%s" { - name = "%s" - }`, localName, name) } func testAccTenantWithProjectEnvironment(localName string, name string, projectLocalName string, primaryEnvironmentLocalName string, secondaryEnvironmentLocalName string) string { @@ -199,3 +174,26 @@ func testAccTenantProjectVariableCheckDestroy(s *terraform.State) error { return nil } + +func testAccProjectWithTemplate(localName string, name string, lifecycleLocalName string, projectGroupLocalName string) string { + return fmt.Sprintf(`resource "octopusdeploy_project" "%s" { + lifecycle_id = octopusdeploy_lifecycle.%s.id + name = "%s" + project_group_id = octopusdeploy_project_group.%s.id + + template { + name = "project variable template name" + label = "project variable template label" + + display_settings = { + "Octopus.ControlType" = "Sensitive" + } + } + }`, localName, lifecycleLocalName, name, projectGroupLocalName) +} + +func testAccProjectGroup(localName string, name string) string { + return fmt.Sprintf(`resource "octopusdeploy_project_group" "%s" { + name = "%s" + }`, localName, name) +} diff --git a/octopusdeploy_framework/space_resource_migration_test.go b/octopusdeploy_framework/space_resource_migration_test.go index 74672539f..4da60b4d0 100644 --- a/octopusdeploy_framework/space_resource_migration_test.go +++ b/octopusdeploy_framework/space_resource_migration_test.go @@ -11,9 +11,10 @@ import ( "github.com/stretchr/testify/assert" ) -func TestSpaceResource_UpgradeFromSDK_ToPluginFramework(t *testing.T) { +func (suite *IntegrationTestSuite) TestSpaceResource_UpgradeFromSDK_ToPluginFramework() { // override the path to check for terraformrc file and test against the real 0.21.1 version os.Setenv("TF_CLI_CONFIG_FILE=", "") + t := suite.T() resource.Test(t, resource.TestCase{ CheckDestroy: testSpaceDestroy, diff --git a/octopusdeploy_framework/testing_container_test.go b/octopusdeploy_framework/testing_container_test.go index b6e7d0f36..9fda04565 100644 --- a/octopusdeploy_framework/testing_container_test.go +++ b/octopusdeploy_framework/testing_container_test.go @@ -6,6 +6,7 @@ import ( "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/client" "github.com/OctopusSolutionsEngineering/OctopusTerraformTestFramework/octoclient" "github.com/OctopusSolutionsEngineering/OctopusTerraformTestFramework/test" + "github.com/stretchr/testify/suite" "github.com/testcontainers/testcontainers-go" "log" "os" @@ -13,61 +14,74 @@ import ( "time" ) -var createSharedContainer = flag.Bool("createSharedContainer", false, "Set to true to run integration tests in containers") +var createSharedContainer = flag.Bool("createSharedContainer", true, "Set to true to run integration tests in containers") +// Note these could and should be removed and replaced by references to the IntegrationTestSuite. +// We haven't done this due to refactoring time. var octoContainer *test.OctopusContainer var octoClient *client.Client -var network testcontainers.Network -var sqlServerContainer *test.MysqlContainer -var err error -func TestMain(m *testing.M) { +type ( + IntegrationTestSuite struct { + suite.Suite + octoContainer *test.OctopusContainer + octoClient *client.Client + network testcontainers.Network + sqlServerContainer *test.MysqlContainer + err error + } +) + +func TestFrameworkIntegrationTestSuite(t *testing.T) { + suite.Run(t, &IntegrationTestSuite{}) +} + +// SetupSuite implements testify's SetupAllSuite interface and runs at the beginning of the test suite, when suite.Run() is called. +func (suite *IntegrationTestSuite) SetupSuite() { flag.Parse() // Parse the flags os.Setenv("TF_ACC", "1") if *createSharedContainer { - testFramework := test.OctopusContainerTest{} - octoContainer, octoClient, sqlServerContainer, network, err = testFramework.ArrangeContainer(m) - if err != nil { - log.Printf("Failed to arrange containers: (%s)", err.Error()) - } + suite.octoContainer, suite.octoClient, suite.sqlServerContainer, suite.network, suite.err = testFramework.ArrangeContainer() + octoContainer = suite.octoContainer + octoClient = suite.octoClient - os.Setenv("OCTOPUS_URL", octoContainer.URI) + os.Setenv("OCTOPUS_URL", suite.octoContainer.URI) os.Setenv("OCTOPUS_APIKEY", test.ApiKey) - - code := m.Run() - ctx := context.Background() - - // Waiting for the container logs to clear. - time.Sleep(10000 * time.Millisecond) - err := testFramework.CleanUp(ctx, octoContainer, sqlServerContainer, network) - - if err != nil { - log.Printf("Failed to clean up containers: (%s)", err.Error()) - panic(m) - } - - log.Printf("Exit code: (%d)", code) - os.Exit(code) } else { if os.Getenv("TF_ACC_LOCAL") != "" { var url = os.Getenv("OCTOPUS_URL") var apikey = os.Getenv("OCTOPUS_APIKEY") - octoClient, err = octoclient.CreateClient(url, "", apikey) - if err != nil { - log.Printf("Failed to create client: (%s)", err.Error()) - panic(m) + suite.octoClient, suite.err = octoclient.CreateClient(url, "", apikey) + if suite.err != nil { + log.Printf("Failed to create client: (%s)", suite.err.Error()) } octoContainer = &test.OctopusContainer{ Container: nil, URI: url, } } - code := m.Run() - os.Exit(code) } } +// TearDownSuite implements testify's TearDownAllSuite interface and runs at the end of the suite. +func (suite *IntegrationTestSuite) TearDownSuite() { + // Waiting for the container logs to clear. + time.Sleep(10000 * time.Millisecond) + testFramework := test.OctopusContainerTest{} + ctx := context.Background() + err := testFramework.CleanUp(ctx, suite.octoContainer, suite.sqlServerContainer, suite.network) + + if err != nil { + log.Printf("Failed to clean up containers: (%s)", err.Error()) + } +} + +// TearDownTest implements testify's TearDownTestSuite interface and runs after each suite of tests. +func (suite *IntegrationTestSuite) TearDownTest() { + +} + func SkipCI(t *testing.T, reason string) { if os.Getenv("Skip_Legacy_Tests") == "" { t.Skip(reason)