Skip to content

Commit

Permalink
Import test for @steveAG's import fix in okta_email_template_settings
Browse files Browse the repository at this point in the history
Closes #2203
  • Loading branch information
monde committed Feb 10, 2025
1 parent f58b11c commit b01c004
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions okta/resource_okta_email_template_settings_test.go
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
package okta

import (
"errors"
"fmt"
"testing"

"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
"github.com/hashicorp/terraform-plugin-sdk/v2/terraform"
)

func TestAccResourceOktaEmailTemplateSettings_crud(t *testing.T) {
Expand Down Expand Up @@ -33,6 +35,26 @@ func TestAccResourceOktaEmailTemplateSettings_crud(t *testing.T) {
resource.TestCheckResourceAttr(resourceName, "template_name", "UserActivation"),
),
},
{
ResourceName: resourceName,
ImportState: true,
ImportStateVerify: true,
ImportStateIdFunc: func(s *terraform.State) (string, error) {
rs, ok := s.RootModule().Resources[resourceName]
if !ok {
return "", fmt.Errorf("failed to find %s", resourceName)
}
brandID := rs.Primary.Attributes["brand_id"]
templateName := rs.Primary.Attributes["template_name"]
return fmt.Sprintf("%s/%s", brandID, templateName), nil
},
ImportStateCheck: func(s []*terraform.InstanceState) error {
if len(s) != 1 {
return errors.New("failed to import schema into state")
}
return nil
},
},
},
})
}

0 comments on commit b01c004

Please sign in to comment.