mg := meta.(*mailgun.MailgunImpl)
ctx, cancel := context.WithTimeout(context.Background(), time.Second*30)
defer cancel()
- domainName := d.Get("name").(string)
+ domainName := d.Id()
mg = mailgun.NewMailgun(domainName, mg.APIKey())
domainResponse, err := mg.GetDomain(ctx, domainName)
if err != nil {
return fmt.Errorf("Error Getting mailgun domain Details for %s: Error: %s", d.Id(), err)
}
+ if _, ok := d.GetOk("dkim_key_size"); !ok {
+ d.Set("dkim_key_size", 1024)
+ }
+
+ if _, ok := d.GetOk("force_dkim_authority"); !ok {
+ d.Set("force_dkim_authority", false)
+ }
d.Set("created_at", domainResponse.Domain.CreatedAt)
d.Set("smtd_login", domainResponse.Domain.SMTPLogin)
})
}
+
+func TestDomain_importBasic(t *testing.T) {
+ var domain fullDomain
+
+ resource.Test(t, resource.TestCase{
+ PreCheck: func() { testAccPreCheck(t) },
+ Providers: testAccProviders,
+ CheckDestroy: testAccDomainCheckDestroy(&domain),
+ Steps: []resource.TestStep{
+ {
+ Config: interpolateTerraformTemplateDomain(testAccDomainConfig_import),
+ Check: resource.ComposeTestCheckFunc(
+ testAccDomainCheckExists("mailgun_domain.exemple",&domain),
+ ),
+ },
+ {
+ ResourceName: "mailgun_domain.exemple",
+ ImportState: true,
+ ImportStateVerify: true,
+ },
+ },
+ })
+}
+
func testAccDomainCheckExists(rn string, domain *fullDomain) resource.TestCheckFunc {
return func(s *terraform.State) error {
rs, ok := s.RootModule().Resources[rn]
}
`
+const testAccDomainConfig_import = `
+resource "mailgun_domain" "exemple" {
+ name = "%s"
+}
+`
})
}
+func TestRoute_importBasic(t *testing.T) {
+ var route mailgun.Route
+
+ resource.Test(t, resource.TestCase{
+ PreCheck: func() { testAccPreCheck(t) },
+ Providers: testAccProviders,
+ CheckDestroy: testAccRouteCheckDestroy(&route),
+ Steps: []resource.TestStep{
+ {
+ Config: testAccRouteConfig_basic,
+ Check: resource.ComposeTestCheckFunc(
+ testAccRouteCheckExists("mailgun_route.exemple",&route),
+ ),
+ },
+ {
+ ResourceName: "mailgun_route.exemple",
+ ImportState: true,
+ ImportStateVerify: true,
+ },
+ },
+ })
+}
+
func testAccRouteCheckExists(rn string, route *mailgun.Route) resource.TestCheckFunc {
return func(s *terraform.State) error {
rs, ok := s.RootModule().Resources[rn]