diff --git a/ovh/data_source_ovh_bankaccount.go b/ovh/data_source_ovh_me_paymentmean_bankaccount.go similarity index 94% rename from ovh/data_source_ovh_bankaccount.go rename to ovh/data_source_ovh_me_paymentmean_bankaccount.go index 843e4f253..295ff4a44 100644 --- a/ovh/data_source_ovh_bankaccount.go +++ b/ovh/data_source_ovh_me_paymentmean_bankaccount.go @@ -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, @@ -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)) diff --git a/ovh/data_source_ovh_me_paymentmean_bankaccount_test.go b/ovh/data_source_ovh_me_paymentmean_bankaccount_test.go new file mode 100644 index 000000000..ae6d0c8a5 --- /dev/null +++ b/ovh/data_source_ovh_me_paymentmean_bankaccount_test.go @@ -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 +} +` diff --git a/ovh/data_source_ovh_creditcard.go b/ovh/data_source_ovh_me_paymentmean_creditcard.go similarity index 94% rename from ovh/data_source_ovh_creditcard.go rename to ovh/data_source_ovh_me_paymentmean_creditcard.go index d5d078df4..c08b80da5 100644 --- a/ovh/data_source_ovh_creditcard.go +++ b/ovh/data_source_ovh_me_paymentmean_creditcard.go @@ -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, @@ -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)) diff --git a/ovh/data_source_ovh_me_paymentmean_creditcard_test.go b/ovh/data_source_ovh_me_paymentmean_creditcard_test.go new file mode 100644 index 000000000..7b741da95 --- /dev/null +++ b/ovh/data_source_ovh_me_paymentmean_creditcard_test.go @@ -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 +} +` diff --git a/ovh/provider.go b/ovh/provider.go index 0901d85ce..a7e9e99de 100644 --- a/ovh/provider.go +++ b/ovh/provider.go @@ -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(),