Skip to content

Commit 1ea84b4

Browse files
committed
fix(tem): properly fail scaleway_tem_domain_validation on timeout
1 parent b8dca3e commit 1ea84b4

File tree

3 files changed

+847
-0
lines changed

3 files changed

+847
-0
lines changed

internal/services/tem/domain_validation.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,15 @@ func ResourceDomainValidationCreate(ctx context.Context, d *schema.ResourceData,
8989
return nil
9090
})
9191

92+
domainCheck, _ := api.CheckDomain(&tem.CheckDomainRequest{
93+
Region: region,
94+
DomainID: domain.ID,
95+
})
96+
if domainCheck == nil || domainCheck.Status == "pending" || domainCheck.Status == "unchecked" || domainCheck.Status == "autoconfiguring" {
97+
d.SetId("")
98+
return diag.Errorf("domain validation did not complete in %d seconds", duration)
99+
}
100+
92101
return ResourceDomainValidationRead(ctx, d, meta)
93102
}
94103

internal/services/tem/domain_validation_test.go

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package tem_test
22

33
import (
44
"fmt"
5+
"regexp"
56
"testing"
67

78
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
@@ -86,3 +87,39 @@ func TestAccDomainValidation_Validation(t *testing.T) {
8687
},
8788
})
8889
}
90+
91+
func TestAccDomainValidation_TimeoutError(t *testing.T) {
92+
tt := acctest.NewTestTools(t)
93+
defer tt.Cleanup()
94+
95+
subDomainName := "validation-timeout"
96+
97+
resource.ParallelTest(t, resource.TestCase{
98+
PreCheck: func() { acctest.PreCheck(t) },
99+
ProviderFactories: tt.ProviderFactories,
100+
CheckDestroy: isDomainDestroyed(tt),
101+
Steps: []resource.TestStep{
102+
{
103+
Config: fmt.Sprintf(`
104+
105+
resource "scaleway_domain_zone" "test" {
106+
domain = "%s"
107+
subdomain = "%s"
108+
}
109+
110+
resource scaleway_tem_domain cr01 {
111+
name = scaleway_domain_zone.test.id
112+
accept_tos = true
113+
}
114+
115+
resource scaleway_tem_domain_validation valid {
116+
domain_id = scaleway_tem_domain.cr01.id
117+
region = scaleway_tem_domain.cr01.region
118+
timeout = 1
119+
}
120+
`, domainNameValidation, subDomainName),
121+
ExpectError: regexp.MustCompile("(?i)domain validation did not complete"),
122+
},
123+
},
124+
})
125+
}

0 commit comments

Comments
 (0)