@@ -16,16 +16,17 @@ import (
16
16
func TestAccAWSLightsailDomain_basic (t * testing.T ) {
17
17
var domain lightsail.Domain
18
18
lightsailDomainName := fmt .Sprintf ("tf-test-lightsail-%s.com" , acctest .RandString (5 ))
19
+ resourceName := "aws_lightsail_domain.test"
19
20
20
21
resource .ParallelTest (t , resource.TestCase {
21
- PreCheck : func () { testAccPreCheck (t ); testAccPreCheckAWSLightsail (t ) },
22
- Providers : testAccProviders ,
23
- CheckDestroy : testAccCheckAWSLightsailDomainDestroy ,
22
+ PreCheck : func () { testAccPreCheck (t ); testAccPreCheckLightsailDomain (t ) },
23
+ ProviderFactories : testAccProviderFactories ,
24
+ CheckDestroy : testAccCheckAWSLightsailDomainDestroy ,
24
25
Steps : []resource.TestStep {
25
26
{
26
27
Config : testAccAWSLightsailDomainConfig_basic (lightsailDomainName ),
27
28
Check : resource .ComposeAggregateTestCheckFunc (
28
- testAccCheckAWSLightsailDomainExists ("aws_lightsail_domain.domain_test" , & domain ),
29
+ testAccCheckAWSLightsailDomainExists (resourceName , & domain ),
29
30
),
30
31
},
31
32
},
@@ -35,30 +36,18 @@ func TestAccAWSLightsailDomain_basic(t *testing.T) {
35
36
func TestAccAWSLightsailDomain_disappears (t * testing.T ) {
36
37
var domain lightsail.Domain
37
38
lightsailDomainName := fmt .Sprintf ("tf-test-lightsail-%s.com" , acctest .RandString (5 ))
38
-
39
- domainDestroy := func (* terraform.State ) error {
40
- conn := testAccProvider .Meta ().(* AWSClient ).lightsailconn
41
- _ , err := conn .DeleteDomain (& lightsail.DeleteDomainInput {
42
- DomainName : aws .String (lightsailDomainName ),
43
- })
44
-
45
- if err != nil {
46
- return fmt .Errorf ("Error deleting Lightsail Domain in disapear test" )
47
- }
48
-
49
- return nil
50
- }
39
+ resourceName := "aws_lightsail_domain.test"
51
40
52
41
resource .ParallelTest (t , resource.TestCase {
53
- PreCheck : func () { testAccPreCheck (t ); testAccPreCheckAWSLightsail (t ) },
54
- Providers : testAccProviders ,
55
- CheckDestroy : testAccCheckAWSLightsailDomainDestroy ,
42
+ PreCheck : func () { testAccPreCheck (t ); testAccPreCheckLightsailDomain (t ) },
43
+ ProviderFactories : testAccProviderFactories ,
44
+ CheckDestroy : testAccCheckAWSLightsailDomainDestroy ,
56
45
Steps : []resource.TestStep {
57
46
{
58
47
Config : testAccAWSLightsailDomainConfig_basic (lightsailDomainName ),
59
48
Check : resource .ComposeAggregateTestCheckFunc (
60
- testAccCheckAWSLightsailDomainExists ("aws_lightsail_domain.domain_test" , & domain ),
61
- domainDestroy ,
49
+ testAccCheckAWSLightsailDomainExists (resourceName , & domain ),
50
+ testAccCheckResourceDisappears ( testAccProviderLightsailDomain , resourceAwsLightsailDomain (), resourceName ) ,
62
51
),
63
52
ExpectNonEmptyPlan : true ,
64
53
},
@@ -77,7 +66,7 @@ func testAccCheckAWSLightsailDomainExists(n string, domain *lightsail.Domain) re
77
66
return errors .New ("No Lightsail Domain ID is set" )
78
67
}
79
68
80
- conn := testAccProvider .Meta ().(* AWSClient ).lightsailconn
69
+ conn := testAccProviderLightsailDomain .Meta ().(* AWSClient ).lightsailconn
81
70
82
71
resp , err := conn .GetDomain (& lightsail.GetDomainInput {
83
72
DomainName : aws .String (rs .Primary .ID ),
@@ -101,7 +90,7 @@ func testAccCheckAWSLightsailDomainDestroy(s *terraform.State) error {
101
90
continue
102
91
}
103
92
104
- conn := testAccProvider .Meta ().(* AWSClient ).lightsailconn
93
+ conn := testAccProviderLightsailDomain .Meta ().(* AWSClient ).lightsailconn
105
94
106
95
resp , err := conn .GetDomain (& lightsail.GetDomainInput {
107
96
DomainName : aws .String (rs .Primary .ID ),
@@ -126,13 +115,11 @@ func testAccCheckAWSLightsailDomainDestroy(s *terraform.State) error {
126
115
}
127
116
128
117
func testAccAWSLightsailDomainConfig_basic (lightsailDomainName string ) string {
129
- return fmt .Sprintf (`
130
- provider "aws" {
131
- region = "us-east-1"
132
- }
133
-
134
- resource "aws_lightsail_domain" "domain_test" {
118
+ return composeConfig (
119
+ testAccLightsailDomainRegionProviderConfig (),
120
+ fmt .Sprintf (`
121
+ resource "aws_lightsail_domain" "test" {
135
122
domain_name = "%s"
136
123
}
137
- ` , lightsailDomainName ) //lintignore:AT004
124
+ ` , lightsailDomainName ))
138
125
}
0 commit comments