From ea87420143b3b217c0b686190ea311e0143580ce Mon Sep 17 00:00:00 2001 From: wuzhuanhong Date: Fri, 27 Dec 2024 09:28:57 +0800 Subject: [PATCH] test(workspace/app): adjust some acceptance tests --- huaweicloud/services/acceptance/acceptance.go | 7 ---- ...e_huaweicloud_workspace_app_groups_test.go | 2 +- ..._workspace_app_group_authorization_test.go | 2 +- ...ce_huaweicloud_workspace_app_group_test.go | 2 +- ...eicloud_workspace_app_policy_group_test.go | 2 +- ...weicloud_workspace_app_publishment_test.go | 33 +++++++++++++++++-- 6 files changed, 34 insertions(+), 14 deletions(-) diff --git a/huaweicloud/services/acceptance/acceptance.go b/huaweicloud/services/acceptance/acceptance.go index 42e4e64f7d..71d40622bf 100644 --- a/huaweicloud/services/acceptance/acceptance.go +++ b/huaweicloud/services/acceptance/acceptance.go @@ -1543,13 +1543,6 @@ func TestAccPreCheckWorkspaceInternetAccessPort(t *testing.T) { } } -// lintignore:AT003 -func TestAccPreCheckWorkspaceAppServerGroupId(t *testing.T) { - if HW_WORKSPACE_APP_SERVER_GROUP_ID == "" { - t.Skip("HW_WORKSPACE_APP_SERVER_GROUP_ID must be set for Workspace service acceptance tests.") - } -} - // lintignore:AT003 func TestAccPreCheckWorkspaceAppServerGroup(t *testing.T) { if HW_WORKSPACE_AD_VPC_ID == "" || HW_WORKSPACE_AD_NETWORK_ID == "" || diff --git a/huaweicloud/services/acceptance/workspace/data_source_huaweicloud_workspace_app_groups_test.go b/huaweicloud/services/acceptance/workspace/data_source_huaweicloud_workspace_app_groups_test.go index 2766671eed..6c0e9c0459 100644 --- a/huaweicloud/services/acceptance/workspace/data_source_huaweicloud_workspace_app_groups_test.go +++ b/huaweicloud/services/acceptance/workspace/data_source_huaweicloud_workspace_app_groups_test.go @@ -10,7 +10,7 @@ import ( "github.com/huaweicloud/terraform-provider-huaweicloud/huaweicloud/services/acceptance" ) -func TestAccDataSourceWorkspaceAppGroups_basic(t *testing.T) { +func TestAccDataSourceAppGroups_basic(t *testing.T) { var ( rName = acceptance.RandomAccResourceName() dataSource = "data.huaweicloud_workspace_app_groups.test" diff --git a/huaweicloud/services/acceptance/workspace/resource_huaweicloud_workspace_app_group_authorization_test.go b/huaweicloud/services/acceptance/workspace/resource_huaweicloud_workspace_app_group_authorization_test.go index 84595f4ae7..96b3fb99ac 100644 --- a/huaweicloud/services/acceptance/workspace/resource_huaweicloud_workspace_app_group_authorization_test.go +++ b/huaweicloud/services/acceptance/workspace/resource_huaweicloud_workspace_app_group_authorization_test.go @@ -74,7 +74,7 @@ func TestAccResourceAppGroupAuthorization_expectErr(t *testing.T) { resource.ParallelTest(t, resource.TestCase{ PreCheck: func() { acceptance.TestAccPreCheck(t) - acceptance.TestAccPreCheckWorkspaceAppServerGroupId(t) + acceptance.TestAccPreCheckWorkspaceAppServerGroup(t) }, ProviderFactories: acceptance.TestAccProviderFactories, CheckDestroy: nil, diff --git a/huaweicloud/services/acceptance/workspace/resource_huaweicloud_workspace_app_group_test.go b/huaweicloud/services/acceptance/workspace/resource_huaweicloud_workspace_app_group_test.go index 351093767f..f9c92f36f2 100644 --- a/huaweicloud/services/acceptance/workspace/resource_huaweicloud_workspace_app_group_test.go +++ b/huaweicloud/services/acceptance/workspace/resource_huaweicloud_workspace_app_group_test.go @@ -41,7 +41,7 @@ func getResourceWorkspaceAppGroupFunc(cfg *config.Config, state *terraform.Resou return resp, err } -func TestAccResourceWorkspaceAppGroup_basic(t *testing.T) { +func TestAccResourceAppGroup_basic(t *testing.T) { var ( resourceName = "huaweicloud_workspace_app_group.test" name = acceptance.RandomAccResourceName() diff --git a/huaweicloud/services/acceptance/workspace/resource_huaweicloud_workspace_app_policy_group_test.go b/huaweicloud/services/acceptance/workspace/resource_huaweicloud_workspace_app_policy_group_test.go index af2319baf7..9e7332a2db 100644 --- a/huaweicloud/services/acceptance/workspace/resource_huaweicloud_workspace_app_policy_group_test.go +++ b/huaweicloud/services/acceptance/workspace/resource_huaweicloud_workspace_app_policy_group_test.go @@ -37,7 +37,7 @@ func TestAccAppPolicyGroup_basic(t *testing.T) { resource.ParallelTest(t, resource.TestCase{ PreCheck: func() { acceptance.TestAccPreCheck(t) - acceptance.TestAccPreCheckWorkspaceAppServerGroupId(t) + acceptance.TestAccPreCheckWorkspaceAppServerGroup(t) }, ProviderFactories: acceptance.TestAccProviderFactories, CheckDestroy: rc.CheckResourceDestroy(), diff --git a/huaweicloud/services/acceptance/workspace/resource_huaweicloud_workspace_app_publishment_test.go b/huaweicloud/services/acceptance/workspace/resource_huaweicloud_workspace_app_publishment_test.go index d547e9ea5c..0bbf05eb42 100644 --- a/huaweicloud/services/acceptance/workspace/resource_huaweicloud_workspace_app_publishment_test.go +++ b/huaweicloud/services/acceptance/workspace/resource_huaweicloud_workspace_app_publishment_test.go @@ -37,7 +37,7 @@ func TestAccAppPublishment_basic(t *testing.T) { resource.ParallelTest(t, resource.TestCase{ PreCheck: func() { acceptance.TestAccPreCheck(t) - acceptance.TestAccPreCheckWorkspaceAppServerGroupId(t) + acceptance.TestAccPreCheckWorkspaceAppServerGroup(t) }, ProviderFactories: acceptance.TestAccProviderFactories, CheckDestroy: rc.CheckResourceDestroy(), @@ -90,6 +90,33 @@ func TestAccAppPublishment_basic(t *testing.T) { }) } +func testAccAppPublishment_base(name string) string { + return fmt.Sprintf(` +resource "huaweicloud_workspace_app_group" "test" { + name = "%[1]s" +} + +resource "huaweicloud_workspace_app_server_group" "test" { + name = "%[1]s" + os_type = "Windows" + flavor_id = "%[2]s" + vpc_id = "%[3]s" + subnet_id = "%[4]s" + system_disk_type = "SAS" + system_disk_size = 80 + is_vdi = true + app_type = "COMMON_APP" + image_id = "%[5]s" + image_type = "gold" + image_product_id = "%[6]s" +} +`, name, acceptance.HW_WORKSPACE_APP_SERVER_GROUP_FLAVOR_ID, + acceptance.HW_WORKSPACE_AD_VPC_ID, + acceptance.HW_WORKSPACE_AD_NETWORK_ID, + acceptance.HW_WORKSPACE_APP_SERVER_GROUP_IMAGE_ID, + acceptance.HW_WORKSPACE_APP_SERVER_GROUP_IMAGE_PRODUCT_ID) +} + func testAccAppPublishment_basic_step1(name string) string { return fmt.Sprintf(` %[1]s @@ -109,7 +136,7 @@ resource "huaweicloud_workspace_app_publishment" "test" { icon_index = 0 status = "FORBIDDEN" } -`, testResourceWorkspaceAppGroup_basic_step1(name), name) +`, testAccAppPublishment_base(name), name) } func testAccAppPublishment_basic_step2(updateName string) string { @@ -127,7 +154,7 @@ resource "huaweicloud_workspace_app_publishment" "test" { icon_index = 0 status = "NORMAL" } -`, testResourceWorkspaceAppGroup_basic_step1(updateName), updateName) +`, testAccAppPublishment_base(updateName), updateName) } func testAppPublishmentImportState(rName string) resource.ImportStateIdFunc {