Skip to content

Commit

Permalink
update tc
Browse files Browse the repository at this point in the history
  • Loading branch information
neil-yechenwei committed Aug 16, 2022
1 parent 093426d commit 0d5ca41
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 48 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,10 @@ func resourcePortalTenantConfigurationCreateUpdate(d *pluginsdk.ResourceData, me
// NOTE: we're using a Terraform-internal Resource ID here since the Go SDK no longer exposes one
// since this is an operation on a Tenant (which doesn't expose any configurable values).
id := parse.NewPortalTenantConfigurationID("default")
if _, err := client.TenantConfigurationsDelete(ctx); err != nil {
return fmt.Errorf("deleting %s: %+v", id, err)
}

if d.IsNewResource() {
existing, err := client.TenantConfigurationsGet(ctx)
if err != nil {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,7 @@ func TestAccPortalTenantConfiguration(t *testing.T) {
// Azure only being able provision one default Tenant Configuration at a time
acceptance.RunTestsInSequence(t, map[string]map[string]func(t *testing.T){
"resource": {
"basic": testAccPortalTenantConfiguration_basic,
"update": testAccPortalTenantConfiguration_update,
"requiresImport": testAccPortalTenantConfiguration_requiresImport,
"basic": testAccPortalTenantConfiguration_basic,
},
})
}
Expand All @@ -41,41 +39,6 @@ func testAccPortalTenantConfiguration_basic(t *testing.T) {
})
}

func testAccPortalTenantConfiguration_requiresImport(t *testing.T) {
data := acceptance.BuildTestData(t, "azurerm_portal_tenant_configuration", "test")
r := PortalTenantConfigurationResource{}
data.ResourceSequentialTest(t, r, []acceptance.TestStep{
{
Config: r.basic(true),
Check: acceptance.ComposeTestCheckFunc(
check.That(data.ResourceName).ExistsInAzure(r),
),
},
data.RequiresImportErrorStep(r.requiresImport),
})
}

func testAccPortalTenantConfiguration_update(t *testing.T) {
data := acceptance.BuildTestData(t, "azurerm_portal_tenant_configuration", "test")
r := PortalTenantConfigurationResource{}
data.ResourceSequentialTest(t, r, []acceptance.TestStep{
{
Config: r.basic(true),
Check: acceptance.ComposeTestCheckFunc(
check.That(data.ResourceName).ExistsInAzure(r),
),
},
data.ImportStep(),
{
Config: r.basic(false),
Check: acceptance.ComposeTestCheckFunc(
check.That(data.ResourceName).ExistsInAzure(r),
),
},
data.ImportStep(),
})
}

func (r PortalTenantConfigurationResource) Exists(ctx context.Context, client *clients.Client, state *pluginsdk.InstanceState) (*bool, error) {
id, err := parse.PortalTenantConfigurationID(state.ID)
if err != nil {
Expand All @@ -101,13 +64,3 @@ resource "azurerm_portal_tenant_configuration" "test" {
}
`, enforcePrivateMarkdownStorage)
}

func (r PortalTenantConfigurationResource) requiresImport(data acceptance.TestData) string {
return fmt.Sprintf(`
%s
resource "azurerm_portal_tenant_configuration" "import" {
private_markdown_storage_enforced = azurerm_portal_tenant_configuration.test.private_markdown_storage_enforced
}
`, r.basic(true))
}

0 comments on commit 0d5ca41

Please sign in to comment.