Skip to content

Commit

Permalink
wrap test
Browse files Browse the repository at this point in the history
  • Loading branch information
njuCZ committed Apr 20, 2021
1 parent 038b312 commit ed1fe9e
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (
type KeyVaultManagedHardwareSecurityModuleDataSource struct {
}

func TestAccDataSourceKeyVaultManagedHardwareSecurityModule_basic(t *testing.T) {
func testAccDataSourceKeyVaultManagedHardwareSecurityModule_basic(t *testing.T) {
data := acceptance.BuildTestData(t, "data.azurerm_key_vault_managed_hardware_security_module", "test")
r := KeyVaultManagedHardwareSecurityModuleDataSource{}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,16 +111,16 @@ func resourceArmKeyVaultManagedHardwareSecurityModuleCreate(d *schema.ResourceDa
log.Println("[INFO] Preparing arguments for Key Vault Managed Hardware Security Module")

id := parse.NewManagedHSMID(subscriptionId, d.Get("resource_group_name").(string), d.Get("name").(string))
existing, err := client.Get(ctx, id.ResourceGroup, id.Name)
if err != nil {
if !utils.ResponseWasNotFound(existing.Response) {
return fmt.Errorf("checking for presence of existing %s: %+v", id, err)
}
}

existing, err := client.Get(ctx, id.ResourceGroup, id.Name)
if err != nil {
if !utils.ResponseWasNotFound(existing.Response) {
return tf.ImportAsExistsError("azurerm_key_vault_managed_hardware_security_module", id.ID())
return fmt.Errorf("checking for presence of existing %s: %+v", id, err)
}
}
if !utils.ResponseWasNotFound(existing.Response) {
return tf.ImportAsExistsError("azurerm_key_vault_managed_hardware_security_module", id.ID())
}

tenantId := uuid.FromStringOrNil(d.Get("tenant_id").(string))
hsm := keyvault.ManagedHsm{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,22 @@ import (
type KeyVaultManagedHardwareSecurityModuleResource struct {
}

func TestAccKeyVaultManagedHardwareSecurityModule_basic(t *testing.T) {
func TestAccSecurityCenter(t *testing.T) {
// NOTE: this is a combined test rather than separate split out tests due to
// Azure only being able provision against one instance at a time
acceptance.RunTestsInSequence(t, map[string]map[string]func(t *testing.T){
"data_source": {
"basic": testAccDataSourceKeyVaultManagedHardwareSecurityModule_basic,
},
"resource": {
"basic": testAccKeyVaultManagedHardwareSecurityModule_basic,
"update": testAccKeyVaultManagedHardwareSecurityModule_requiresImport,
"complete": testAccKeyVaultManagedHardwareSecurityModule_complete,
},
})
}

func testAccKeyVaultManagedHardwareSecurityModule_basic(t *testing.T) {
data := acceptance.BuildTestData(t, "azurerm_key_vault_managed_hardware_security_module", "test")
r := KeyVaultManagedHardwareSecurityModuleResource{}

Expand All @@ -32,7 +47,7 @@ func TestAccKeyVaultManagedHardwareSecurityModule_basic(t *testing.T) {
})
}

func TestAccKeyVaultManagedHardwareSecurityModule_requiresImport(t *testing.T) {
func testAccKeyVaultManagedHardwareSecurityModule_requiresImport(t *testing.T) {
data := acceptance.BuildTestData(t, "azurerm_key_vault_managed_hardware_security_module", "test")
r := KeyVaultManagedHardwareSecurityModuleResource{}

Expand All @@ -47,7 +62,7 @@ func TestAccKeyVaultManagedHardwareSecurityModule_requiresImport(t *testing.T) {
})
}

func TestAccKeyVaultManagedHardwareSecurityModule_complete(t *testing.T) {
func testAccKeyVaultManagedHardwareSecurityModule_complete(t *testing.T) {
data := acceptance.BuildTestData(t, "azurerm_key_vault_managed_hardware_security_module", "test")
r := KeyVaultManagedHardwareSecurityModuleResource{}

Expand Down

0 comments on commit ed1fe9e

Please sign in to comment.