Skip to content

Commit

Permalink
add additional data source test case
Browse files Browse the repository at this point in the history
  • Loading branch information
sreekarbvibm committed Nov 21, 2023
1 parent 6938129 commit bf21286
Showing 1 changed file with 38 additions and 2 deletions.
40 changes: 38 additions & 2 deletions ibm/service/vpc/data_source_ibm_is_reservation_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"),
Expand All @@ -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 {
Expand All @@ -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
}`)
}

0 comments on commit bf21286

Please sign in to comment.