From bf212860e737712aa5010cd841ef3759cb60e68f Mon Sep 17 00:00:00 2001 From: sreekarbvibm <139211144+sreekarbvibm@users.noreply.github.com> Date: Tue, 21 Nov 2023 19:40:32 +0530 Subject: [PATCH] add additional data source test case --- .../data_source_ibm_is_reservation_test.go | 40 ++++++++++++++++++- 1 file changed, 38 insertions(+), 2 deletions(-) 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 + }`) +}