@@ -3,6 +3,7 @@ package argo_smart_routing_test
3
3
import (
4
4
"fmt"
5
5
"os"
6
+ "regexp"
6
7
"testing"
7
8
8
9
"github.com/cloudflare/terraform-provider-cloudflare/internal/acctest"
@@ -17,21 +18,63 @@ func TestAccCloudflareArgoSmartRouting_Basic(t *testing.T) {
17
18
18
19
resource .Test (t , resource.TestCase {
19
20
PreCheck : func () {
20
- acctest .TestAccPreCheck_AccountID (t )
21
+ acctest .TestAccPreCheck_ZoneID (t )
21
22
acctest .TestAccPreCheck_Credentials (t )
22
23
},
23
24
ProtoV6ProviderFactories : acctest .TestAccProtoV6ProviderFactories ,
24
25
Steps : []resource.TestStep {
25
26
{
26
- Config : testAccCheckCloudflareArgoSmartRoutingBasic (zoneID , rnd ),
27
+ Config : testAccCheckCloudflareArgoSmartRoutingEnable (zoneID , rnd ),
27
28
Check : resource .ComposeTestCheckFunc (
29
+ resource .TestCheckResourceAttr (name , "id" , zoneID ),
30
+ resource .TestCheckResourceAttr (name , "zone_id" , zoneID ),
28
31
resource .TestCheckResourceAttr (name , "value" , "on" ),
29
32
),
30
33
},
34
+ {
35
+ Config : testAccCheckCloudflareArgoSmartRoutingDisable (zoneID , rnd ),
36
+ Check : resource .ComposeTestCheckFunc (
37
+ resource .TestCheckResourceAttr (name , "id" , zoneID ),
38
+ resource .TestCheckResourceAttr (name , "zone_id" , zoneID ),
39
+ resource .TestCheckResourceAttr (name , "value" , "off" ),
40
+ ),
41
+ },
42
+ {
43
+ ResourceName : name ,
44
+ ImportState : true ,
45
+ ImportStateVerify : true ,
46
+ },
31
47
},
32
48
})
33
49
}
34
50
35
- func testAccCheckCloudflareArgoSmartRoutingBasic (zoneID , name string ) string {
36
- return acctest .LoadTestCase ("basic.tf" , zoneID , name )
51
+ func TestAccCloudflareArgoSmartRouting_InvalidValue (t * testing.T ) {
52
+ zoneID := os .Getenv ("CLOUDFLARE_ZONE_ID" )
53
+ rnd := utils .GenerateRandomResourceName ()
54
+
55
+ resource .Test (t , resource.TestCase {
56
+ PreCheck : func () {
57
+ acctest .TestAccPreCheck_AccountID (t )
58
+ acctest .TestAccPreCheck_Credentials (t )
59
+ },
60
+ ProtoV6ProviderFactories : acctest .TestAccProtoV6ProviderFactories ,
61
+ Steps : []resource.TestStep {
62
+ {
63
+ Config : testAccCheckCloudflareArgoSmartRoutingInvalidValue (zoneID , rnd ),
64
+ ExpectError : regexp .MustCompile (regexp .QuoteMeta ("Invalid Attribute Value Match" )),
65
+ },
66
+ },
67
+ })
68
+ }
69
+
70
+ func testAccCheckCloudflareArgoSmartRoutingEnable (zoneID , name string ) string {
71
+ return acctest .LoadTestCase ("enable.tf" , zoneID , name )
72
+ }
73
+
74
+ func testAccCheckCloudflareArgoSmartRoutingDisable (zoneID , name string ) string {
75
+ return acctest .LoadTestCase ("disable.tf" , zoneID , name )
76
+ }
77
+
78
+ func testAccCheckCloudflareArgoSmartRoutingInvalidValue (zoneID , name string ) string {
79
+ return acctest .LoadTestCase ("invalid_value.tf" , zoneID , name )
37
80
}
0 commit comments