Skip to content

Commit

Permalink
Adding Import tests for Role Definitions
Browse files Browse the repository at this point in the history
```
$ 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
```
  • Loading branch information
tombuildsstuff committed Oct 11, 2017
1 parent 6d8ebaa commit 3311808
Show file tree
Hide file tree
Showing 2 changed files with 60 additions and 0 deletions.
59 changes: 59 additions & 0 deletions azurerm/import_arm_role_definition_test.go
Original file line number Diff line number Diff line change
@@ -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"},
},
},
})
}
1 change: 1 addition & 0 deletions azurerm/resource_arm_role_definition.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ func resourceArmRoleDefinition() *schema.Resource {
Required: true,
ForceNew: true,
},

"name": {
Type: schema.TypeString,
Required: true,
Expand Down

0 comments on commit 3311808

Please sign in to comment.