From 33118089a73b22cdc1afa2c8e7510b8701b0f030 Mon Sep 17 00:00:00 2001 From: tombuildsstuff Date: Wed, 11 Oct 2017 13:38:31 +0100 Subject: [PATCH] Adding Import tests for Role Definitions ``` $ acctests azurerm TestAccAzureRMRoleDefinition_import === RUN TestAccAzureRMRoleDefinition_importBasic --- PASS: TestAccAzureRMRoleDefinition_importBasic (16.32s) === RUN TestAccAzureRMRoleDefinition_importComplete --- PASS: TestAccAzureRMRoleDefinition_importComplete (14.12s) PASS ok github.com/terraform-providers/terraform-provider-azurerm/azurerm 30.462s ``` --- azurerm/import_arm_role_definition_test.go | 59 ++++++++++++++++++++++ azurerm/resource_arm_role_definition.go | 1 + 2 files changed, 60 insertions(+) create mode 100644 azurerm/import_arm_role_definition_test.go diff --git a/azurerm/import_arm_role_definition_test.go b/azurerm/import_arm_role_definition_test.go new file mode 100644 index 000000000000..bfead9cc6c1c --- /dev/null +++ b/azurerm/import_arm_role_definition_test.go @@ -0,0 +1,59 @@ +package azurerm + +import ( + "testing" + + "github.com/google/uuid" + "github.com/hashicorp/terraform/helper/acctest" + "github.com/hashicorp/terraform/helper/resource" +) + +func TestAccAzureRMRoleDefinition_importBasic(t *testing.T) { + resourceName := "azurerm_role_definition.test" + + id := uuid.New().String() + ri := acctest.RandInt() + config := testAccAzureRMRoleDefinition_basic(id, ri) + + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + Providers: testAccProviders, + CheckDestroy: testCheckAzureRMRoleDefinitionDestroy, + Steps: []resource.TestStep{ + { + Config: config, + }, + { + ResourceName: resourceName, + ImportState: true, + ImportStateVerify: true, + ImportStateVerifyIgnore: []string{"role_definition_id", "scope"}, + }, + }, + }) +} + +func TestAccAzureRMRoleDefinition_importComplete(t *testing.T) { + resourceName := "azurerm_role_definition.test" + + id := uuid.New().String() + ri := acctest.RandInt() + config := testAccAzureRMRoleDefinition_complete(id, ri) + + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + Providers: testAccProviders, + CheckDestroy: testCheckAzureRMRoleDefinitionDestroy, + Steps: []resource.TestStep{ + { + Config: config, + }, + { + ResourceName: resourceName, + ImportState: true, + ImportStateVerify: true, + ImportStateVerifyIgnore: []string{"role_definition_id", "scope"}, + }, + }, + }) +} diff --git a/azurerm/resource_arm_role_definition.go b/azurerm/resource_arm_role_definition.go index 7c71dce588f6..c6cae45beddb 100644 --- a/azurerm/resource_arm_role_definition.go +++ b/azurerm/resource_arm_role_definition.go @@ -26,6 +26,7 @@ func resourceArmRoleDefinition() *schema.Resource { Required: true, ForceNew: true, }, + "name": { Type: schema.TypeString, Required: true,