Skip to content

Refactor paymentmeans to reflect convention #52

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 11, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ type BankAccount struct {
Bic string `json:"bic"`
}

func dataSourceBankAccount() *schema.Resource {
func dataSourceMePaymentmeanBankaccount() *schema.Resource {
return &schema.Resource{
Read: dataSourceBankAccountRead,
Read: dataSourceMePaymentmeanBankaccountRead,
Schema: map[string]*schema.Schema{
"description_regexp": &schema.Schema{
Type: schema.TypeString,
Expand Down Expand Up @@ -63,7 +63,7 @@ func dataSourceBankAccount() *schema.Resource {
}
}

func dataSourceBankAccountRead(d *schema.ResourceData, meta interface{}) error {
func dataSourceMePaymentmeanBankaccountRead(d *schema.ResourceData, meta interface{}) error {
config := meta.(*Config)
state, state_ok := d.GetOk("state")
description_regexp := regexp.MustCompile(d.Get("description_regexp").(string))
Expand Down
36 changes: 36 additions & 0 deletions ovh/data_source_ovh_me_paymentmean_bankaccount_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
package ovh

import (
"os"
"testing"

"github.com/hashicorp/terraform/helper/resource"
)

func TestAccMePaymentmeanBankaccountDataSource_basic(t *testing.T) {
// ovh bank account payment mean is not mandatory
// this datasource is tested only if env var `OVH_TEST_BANKACCOUNT`
// is set to "1"
v := os.Getenv("OVH_TEST_BANKACCOUNT")
if v == "1" {
resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
Steps: []resource.TestStep{
resource.TestStep{
Config: testAccMePaymentmeanBankaccountDatasourceConfig,
Check: resource.ComposeTestCheckFunc(
resource.TestCheckResourceAttr(
"data.ovh_me_paymentmean_bankaccount.ba", "default", "true"),
),
},
},
})
}
}

const testAccMePaymentmeanBankaccountDatasourceConfig = `
data "ovh_me_paymentmean_bankaccount" "ba" {
use_default = true
}
`
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ type CreditCard struct {
Type string `json:"type"`
}

func dataSourceCreditCard() *schema.Resource {
func dataSourceMePaymentmeanCreditcard() *schema.Resource {
return &schema.Resource{
Read: dataSourceCreditCardRead,
Read: dataSourceMePaymentmeanCreditcardRead,
Schema: map[string]*schema.Schema{
"description_regexp": &schema.Schema{
Type: schema.TypeString,
Expand Down Expand Up @@ -65,7 +65,7 @@ func dataSourceCreditCard() *schema.Resource {
}
}

func dataSourceCreditCardRead(d *schema.ResourceData, meta interface{}) error {
func dataSourceMePaymentmeanCreditcardRead(d *schema.ResourceData, meta interface{}) error {
config := meta.(*Config)
states_val, states_ok := d.GetOk("states")
description_regexp := regexp.MustCompile(d.Get("description_regexp").(string))
Expand Down
36 changes: 36 additions & 0 deletions ovh/data_source_ovh_me_paymentmean_creditcard_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
package ovh

import (
"os"
"testing"

"github.com/hashicorp/terraform/helper/resource"
)

func TestAccMePaymentmeanCreditcardDataSource_basic(t *testing.T) {
// ovh credit card payment mean is not mandatory
// this datasource is tested only if env var `OVH_TEST_CREDITCARD`
// is set to "1"
v := os.Getenv("OVH_TEST_CREDITCARD")
if v == "1" {
resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
Steps: []resource.TestStep{
resource.TestStep{
Config: testAccMePaymentmeanCreditcardDatasourceConfig,
Check: resource.ComposeTestCheckFunc(
resource.TestCheckResourceAttr(
"data.ovh_me_paymentmean_creditcard.cc", "default", "true"),
),
},
},
})
}
}

const testAccMePaymentmeanCreditcardDatasourceConfig = `
data "ovh_me_paymentmean_creditcard" "cc" {
use_default = true
}
`
12 changes: 6 additions & 6 deletions ovh/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,12 @@ func Provider() terraform.ResourceProvider {

DataSourcesMap: map[string]*schema.Resource{
// New naming schema (issue #23)
"ovh_bank_account": dataSourceBankAccount(),
"ovh_cloud_region": dataSourcePublicCloudRegion(),
"ovh_cloud_regions": dataSourcePublicCloudRegions(),
"ovh_credit_card": dataSourceCreditCard(),
"ovh_domain_zone": dataSourceDomainZone(),
"ovh_iploadbalancing": dataSourceIpLoadbalancing(),
"ovh_cloud_region": dataSourcePublicCloudRegion(),
"ovh_cloud_regions": dataSourcePublicCloudRegions(),
"ovh_domain_zone": dataSourceDomainZone(),
"ovh_iploadbalancing": dataSourceIpLoadbalancing(),
"ovh_me_paymentmean_bankaccount": dataSourceMePaymentmeanBankaccount(),
"ovh_me_paymentmean_creditcard": dataSourceMePaymentmeanCreditcard(),

// Legacy naming schema (new datasources should not be added here)
"ovh_publiccloud_region": dataSourcePublicCloudRegion(),
Expand Down