Skip to content

Commit

Permalink
don't throw exception for list TP datsource when there is no TP in th…
Browse files Browse the repository at this point in the history
…e account
  • Loading branch information
Somchavan authored and hkantare committed Apr 15, 2023
1 parent b33a0e6 commit 97e38cb
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 6 deletions.
6 changes: 6 additions & 0 deletions ibm/acctest/acctest.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ var CosName string
var Ibmid1 string
var Ibmid2 string
var IAMUser string
var IAMAccountId string
var Datacenter string
var MachineType string
var trustedMachineType string
Expand Down Expand Up @@ -296,6 +297,11 @@ func init() {
fmt.Println("[WARN] Set the environment variable IBM_IAMUSER for testing ibm_iam_user_policy resource Some tests for that resource will fail if this is not set correctly")
}

IAMAccountId = os.Getenv("IBM_IAMACCOUNTID")
if IAMAccountId == "" {
fmt.Println("[WARN] Set the environment variable IBM_IAMACCOUNTID for testing ibm_iam_trusted_profile resource Some tests for that resource will fail if this is not set correctly")
}

Datacenter = os.Getenv("IBM_DATACENTER")
if Datacenter == "" {
Datacenter = "par01"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -213,10 +213,6 @@ func dataSourceIBMIamTrustedProfileListRead(context context.Context, d *schema.R
break
}
}
if len(allrecs) == 0 {
return diag.FromErr(fmt.Errorf("[ERROR] No profiles found [%s]", accountID))

}

d.SetId(dataSourceIBMIamTrustedProfileListID(d))

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
package iamidentity_test

import (
"fmt"
"testing"

acc "github.com/IBM-Cloud/terraform-provider-ibm/ibm/acctest"
Expand All @@ -30,9 +31,11 @@ func TestAccIBMIamTrustedProfilesDataSourceBasic(t *testing.T) {
}

func testAccCheckIBMIamTrustedProfilesDataSourceConfigBasic() string {
return `
return fmt.Sprintf(`
data "ibm_iam_trusted_profiles" "iam_trusted_profiles" {
account_id = "%s"
name = "name"
}
`
`, acc.IAMAccountId)
}

0 comments on commit 97e38cb

Please sign in to comment.