Skip to content

Commit

Permalink
Renamed fixed_plan to essentials_plan
Browse files Browse the repository at this point in the history
  • Loading branch information
JohnSharpe committed May 7, 2024
1 parent 891926c commit 0ddfe33
Show file tree
Hide file tree
Showing 5 changed files with 150 additions and 150 deletions.
Original file line number Diff line number Diff line change
@@ -1,25 +1,25 @@
---
layout: "rediscloud"
page_title: "Redis Cloud: rediscloud_fixed_plan"
page_title: "Redis Cloud: rediscloud_essentials_plan"
description: |-
Fixed Plan data source in the Terraform provider Redis Cloud.
Essentials Plan data source in the Terraform provider Redis Cloud.
---

# Data Source: rediscloud_fixed_plan
# Data Source: rediscloud_essentials_plan

The Fixed Plan data source allows access to the templates for Fixed Subscriptions.
The Essentials Plan data source allows access to the templates for Essentials Subscriptions.

## Example Usage

```hcl
data "rediscloud_fixed_plan" "example" {
data "rediscloud_essentials_plan" "example" {
name = "Single-Zone_1GB"
provider = "AWS"
region = "us-west-1"
}
output "rediscloud_fixed_plan" {
value = data.rediscloud_fixed_plan.example.id
output "rediscloud_essentials_plan" {
value = data.rediscloud_essentials_plan.example.id
}
```

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ import (
"strings"
)

func dataSourceRedisCloudFixedPlan() *schema.Resource {
func dataSourceRedisCloudEssentialsPlan() *schema.Resource {
return &schema.Resource{
Description: "",
ReadContext: dataSourceRedisCloudFixedPlanRead,
Description: "An Essentials subscription plan",
ReadContext: dataSourceRedisCloudEssentialsPlanRead,

Schema: map[string]*schema.Schema{
"id": {
Expand Down Expand Up @@ -145,7 +145,7 @@ func dataSourceRedisCloudFixedPlan() *schema.Resource {
}
}

func dataSourceRedisCloudFixedPlanRead(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics {
func dataSourceRedisCloudEssentialsPlanRead(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics {
var diags diag.Diagnostics
api := meta.(*apiClient)

Expand Down
138 changes: 138 additions & 0 deletions provider/datasource_rediscloud_essentials_plan_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,138 @@
package provider

import (
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
"regexp"
"testing"
)

func TestAccDataSourceRedisCloudEssentialsPlan_basic(t *testing.T) {

resource.ParallelTest(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
ProviderFactories: providerFactories,
CheckDestroy: nil, // Essentials Plans aren't managed by this provider
Steps: []resource.TestStep{
{
Config: testAccDataSourceRedisCloudEssentialsPlan,
Check: resource.ComposeTestCheckFunc(
resource.TestCheckResourceAttr("data.rediscloud_essentials_plan.basic", "id", "34843"),
resource.TestCheckResourceAttr("data.rediscloud_essentials_plan.basic", "name", "30MB"),
resource.TestCheckResourceAttr("data.rediscloud_essentials_plan.basic", "size", "30"),
resource.TestCheckResourceAttr("data.rediscloud_essentials_plan.basic", "size_measurement_unit", "MB"),
resource.TestCheckResourceAttr("data.rediscloud_essentials_plan.basic", "cloud_provider", "AWS"),
resource.TestCheckResourceAttr("data.rediscloud_essentials_plan.basic", "region", "us-east-1"),
resource.TestCheckResourceAttr("data.rediscloud_essentials_plan.basic", "region_id", "1"),
resource.TestCheckResourceAttrSet("data.rediscloud_essentials_plan.basic", "price"),
resource.TestCheckResourceAttr("data.rediscloud_essentials_plan.basic", "price_currency", "USD"),
resource.TestCheckResourceAttr("data.rediscloud_essentials_plan.basic", "price_period", "Month"),
resource.TestCheckResourceAttr("data.rediscloud_essentials_plan.basic", "maximum_databases", "1"),
resource.TestCheckResourceAttr("data.rediscloud_essentials_plan.basic", "maximum_throughput", "100"),
resource.TestCheckResourceAttr("data.rediscloud_essentials_plan.basic", "maximum_bandwidth_in_gb", "5"),
resource.TestCheckResourceAttr("data.rediscloud_essentials_plan.basic", "availability", "No replication"),
resource.TestCheckResourceAttr("data.rediscloud_essentials_plan.basic", "connections", "30"),
resource.TestCheckResourceAttr("data.rediscloud_essentials_plan.basic", "cidr_allow_rules", "1"),
resource.TestCheckResourceAttr("data.rediscloud_essentials_plan.basic", "support_data_persistence", "false"),
resource.TestCheckResourceAttr("data.rediscloud_essentials_plan.basic", "support_instant_and_daily_backups", "false"),
resource.TestCheckResourceAttr("data.rediscloud_essentials_plan.basic", "support_replication", "false"),
resource.TestCheckResourceAttr("data.rediscloud_essentials_plan.basic", "support_clustering", "false"),
resource.TestCheckResourceAttr("data.rediscloud_essentials_plan.basic", "supported_alerts.#", "2"),
resource.TestCheckResourceAttr("data.rediscloud_essentials_plan.basic", "customer_support", "Basic"),
),
},
},
})
}

func TestAccDataSourceRedisCloudEssentialsPlan_azure(t *testing.T) {

resource.ParallelTest(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
ProviderFactories: providerFactories,
CheckDestroy: nil, // Essentials Plans aren't managed by this provider
Steps: []resource.TestStep{
{
Config: testAccDataSourceRedisCloudEssentialsPlanAzure,
Check: resource.ComposeTestCheckFunc(
resource.TestCheckResourceAttr("data.rediscloud_essentials_plan.azure", "id", "35008"),
resource.TestCheckResourceAttr("data.rediscloud_essentials_plan.azure", "name", "Single-Zone_Persistence_1GB"),
resource.TestCheckResourceAttr("data.rediscloud_essentials_plan.azure", "size", "1"),
resource.TestCheckResourceAttr("data.rediscloud_essentials_plan.azure", "size_measurement_unit", "GB"),
resource.TestCheckResourceAttr("data.rediscloud_essentials_plan.azure", "cloud_provider", "Azure"),
resource.TestCheckResourceAttr("data.rediscloud_essentials_plan.azure", "region", "west-us"),
resource.TestCheckResourceAttr("data.rediscloud_essentials_plan.azure", "region_id", "17"),
resource.TestCheckResourceAttrSet("data.rediscloud_essentials_plan.azure", "price"),
resource.TestCheckResourceAttr("data.rediscloud_essentials_plan.azure", "price_currency", "USD"),
resource.TestCheckResourceAttr("data.rediscloud_essentials_plan.azure", "price_period", "Month"),
resource.TestCheckResourceAttr("data.rediscloud_essentials_plan.azure", "maximum_databases", "1"),
resource.TestCheckResourceAttr("data.rediscloud_essentials_plan.azure", "maximum_throughput", "2000"),
resource.TestCheckResourceAttr("data.rediscloud_essentials_plan.azure", "maximum_bandwidth_in_gb", "200"),
resource.TestCheckResourceAttr("data.rediscloud_essentials_plan.azure", "availability", "Single-zone"),
resource.TestCheckResourceAttr("data.rediscloud_essentials_plan.azure", "connections", "1024"),
resource.TestCheckResourceAttr("data.rediscloud_essentials_plan.azure", "cidr_allow_rules", "8"),
resource.TestCheckResourceAttr("data.rediscloud_essentials_plan.azure", "support_data_persistence", "true"),
resource.TestCheckResourceAttr("data.rediscloud_essentials_plan.azure", "support_instant_and_daily_backups", "true"),
resource.TestCheckResourceAttr("data.rediscloud_essentials_plan.azure", "support_replication", "true"),
resource.TestCheckResourceAttr("data.rediscloud_essentials_plan.azure", "support_clustering", "false"),
resource.TestCheckResourceAttr("data.rediscloud_essentials_plan.azure", "supported_alerts.#", "5"),
resource.TestCheckResourceAttr("data.rediscloud_essentials_plan.azure", "customer_support", "Standard"),
),
},
},
})
}

func TestAccDataSourceRedisCloudEssentialsPlan_ambiguous(t *testing.T) {

resource.ParallelTest(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
ProviderFactories: providerFactories,
CheckDestroy: nil, // Essentials Plans aren't managed by this provider
Steps: []resource.TestStep{
{
Config: testAccDataSourceRedisCloudEssentialsPlanAmbiguous,
ExpectError: regexp.MustCompile("Your query returned more than one result. Please change try a more specific search criteria and try again."),
},
},
})
}

func TestAccDataSourceRedisCloudEssentialsPlan_impossible(t *testing.T) {

resource.ParallelTest(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
ProviderFactories: providerFactories,
CheckDestroy: nil, // Essentials Plans aren't managed by this provider
Steps: []resource.TestStep{
{
Config: testAccDataSourceRedisCloudEssentialsPlanImpossible,
ExpectError: regexp.MustCompile("Your query returned no results. Please change your search criteria and try again."),
},
},
})
}

const testAccDataSourceRedisCloudEssentialsPlan = `
data "rediscloud_essentials_plan" "basic" {
id = 34843
}
`

const testAccDataSourceRedisCloudEssentialsPlanAzure = `
data "rediscloud_essentials_plan" "azure" {
id = 35008
cloud_provider = "Azure"
}
`

const testAccDataSourceRedisCloudEssentialsPlanAmbiguous = `
data "rediscloud_essentials_plan" "ambiguous" {
name = "30MB"
}
`

const testAccDataSourceRedisCloudEssentialsPlanImpossible = `
data "rediscloud_essentials_plan" "impossible" {
name = "There should never be a essentials plan with this name!"
}
`
138 changes: 0 additions & 138 deletions provider/datasource_rediscloud_fixed_plan_test.go

This file was deleted.

2 changes: 1 addition & 1 deletion provider/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ func New(version string) func() *schema.Provider {
"rediscloud_acl_rule": dataSourceRedisCloudAclRule(),
"rediscloud_acl_role": dataSourceRedisCloudAclRole(),
"rediscloud_acl_user": dataSourceRedisCloudAclUser(),
"rediscloud_fixed_plan": dataSourceRedisCloudFixedPlan(),
"rediscloud_essentials_plan": dataSourceRedisCloudEssentialsPlan(),
},
ResourcesMap: map[string]*schema.Resource{
"rediscloud_cloud_account": resourceRedisCloudCloudAccount(),
Expand Down

0 comments on commit 0ddfe33

Please sign in to comment.