diff --git a/ibm/service/vpc/data_source_ibm_is_reservation_test.go b/ibm/service/vpc/data_source_ibm_is_reservation_test.go index f8f7f13f6c..b91644ee1b 100644 --- a/ibm/service/vpc/data_source_ibm_is_reservation_test.go +++ b/ibm/service/vpc/data_source_ibm_is_reservation_test.go @@ -18,7 +18,7 @@ func TestAccIBMISReservationDatasource_basic(t *testing.T) { Providers: acc.TestAccProviders, Steps: []resource.TestStep{ { - Config: testDSCheckIBMISReservationConfig(), + Config: testDSCheckIBMISReservationConfigById(), Check: resource.ComposeTestCheckFunc( resource.TestCheckResourceAttrSet("data.ibm_is_reservation.ds_res", "id"), resource.TestCheckResourceAttrSet("data.ibm_is_reservation.ds_res", "created_at"), @@ -32,11 +32,26 @@ func TestAccIBMISReservationDatasource_basic(t *testing.T) { resource.TestCheckResourceAttrSet("data.ibm_is_reservation.ds_res", "zone"), ), }, + { + Config: testDSCheckIBMISReservationConfigByName(), + Check: resource.ComposeTestCheckFunc( + resource.TestCheckResourceAttrSet("data.ibm_is_reservation.ds_res", "name"), + resource.TestCheckResourceAttrSet("data.ibm_is_reservation.ds_res", "created_at"), + resource.TestCheckResourceAttrSet("data.ibm_is_reservation.ds_res", "crn"), + resource.TestCheckResourceAttrSet("data.ibm_is_reservation.ds_res", "href"), + resource.TestCheckResourceAttrSet("data.ibm_is_reservation.ds_res", "lifecycle_state"), + resource.TestCheckResourceAttrSet("data.ibm_is_reservation.ds_res", "name"), + resource.TestCheckResourceAttrSet("data.ibm_is_reservation.ds_res", "profile.#"), + resource.TestCheckResourceAttrSet("data.ibm_is_reservation.ds_res", "resource_group.#"), + resource.TestCheckResourceAttrSet("data.ibm_is_reservation.ds_res", "resource_type"), + resource.TestCheckResourceAttrSet("data.ibm_is_reservation.ds_res", "zone"), + ), + }, }, }) } -func testDSCheckIBMISReservationConfig() string { +func testDSCheckIBMISReservationConfigById() string { return fmt.Sprintf(` resource "ibm_is_reservation" "res" { capacity { @@ -56,3 +71,24 @@ func testDSCheckIBMISReservationConfig() string { identifier = ibm_is_reservation.res.id }`) } + +func testDSCheckIBMISReservationConfigByName() string { + return fmt.Sprintf(` + resource "ibm_is_reservation" "res" { + capacity { + total = 5 + } + committed_use { + term = "one_year" + } + profile { + name = "cx2-2x4" + resource_type = "instance_profile" + } + zone = "us-south-1" + name = "reservation-name" + } + data "ibm_is_reservation" "ds_res" { + name = ibm_is_reservation.res.name + }`) +}