-
Notifications
You must be signed in to change notification settings - Fork 545
/
resource_cloudflare_tiered_cache_test.go
58 lines (51 loc) · 1.48 KB
/
resource_cloudflare_tiered_cache_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
package provider
import (
"fmt"
"os"
"testing"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
)
func testTieredCacheConfig(rnd, zoneId, cacheType string) string {
return fmt.Sprintf(`
resource "cloudflare_tiered_cache" "%[1]s" {
zone_id = "%[2]s"
cache_type "%[3]s"
}
`, rnd, zoneID, cacheType)
}
func TestCloudflareSmartTieredCache(t *testing.T) {
rnd := generateRandomResourceName()
name := "cloudflare_tiered_cache." + rnd
zoneID := os.Getenv("CLOUDFLARE_ZONE_ID")
resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
ProviderFactories: providerFactories,
Steps: []resource.TestStep{
{
Config: testTieredCacheConfig(rnd, zoneID, "smart"),
Check: resource.ComposeTestCheckFunc(
resource.TestCheckResourceAttr(name, "zone_id", zoneID),
resource.TestCheckResourceAttr(name, "cache_type", "smart"),
),
},
},
})
}
func TestCloudflareGenericTieredCache(t *testing.T) {
rnd := generateRandomResourceName()
name := "cloudflare_tiered_cache." + rnd
zoneID := os.Getenv("CLOUDFLARE_ZONE_ID")
resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
ProviderFactories: providerFactories,
Steps: []resource.TestStep{
{
Config: testTieredCacheConfig(rnd, zoneID, "generic"),
Check: resource.ComposeTestCheckFunc(
resource.TestCheckResourceAttr(name, "zone_id", zoneID),
resource.TestCheckResourceAttr(name, "cache_type", "generic"),
),
},
},
})
}