-
Notifications
You must be signed in to change notification settings - Fork 676
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(Catalog Management): fix cm validation resource panic (#5172)
* fix(Catalog Management): fix cm validation resource panic * fix(Catalog Management): nil check on empty env vars * test(Catalog Management): add validation test
- Loading branch information
1 parent
446d3e1
commit 8c35790
Showing
3 changed files
with
85 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
70 changes: 70 additions & 0 deletions
70
ibm/service/catalogmanagement/resource_ibm_cm_validation_test.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
// Copyright IBM Corp. 2022 All Rights Reserved. | ||
// Licensed under the Mozilla Public License v2.0 | ||
|
||
package catalogmanagement_test | ||
|
||
import ( | ||
"fmt" | ||
"testing" | ||
|
||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" | ||
"github.com/hashicorp/terraform-plugin-sdk/v2/terraform" | ||
|
||
acc "github.com/IBM-Cloud/terraform-provider-ibm/ibm/acctest" | ||
"github.com/IBM/platform-services-go-sdk/catalogmanagementv1" | ||
) | ||
|
||
func TestAccIBMCmValidationSimpleArgs(t *testing.T) { | ||
var conf catalogmanagementv1.Version | ||
versionLocator := "dba7e7dd-2bd7-4fcd-a846-4c370eab2672.98ba725b-86fa-4c6a-8430-70f38ec988da" | ||
|
||
resource.Test(t, resource.TestCase{ | ||
PreCheck: func() { acc.TestAccPreCheck(t) }, | ||
Providers: acc.TestAccProviders, | ||
CheckDestroy: testAccCheckIBMCmValidationDestroy, | ||
Steps: []resource.TestStep{ | ||
resource.TestStep{ | ||
Config: testAccCheckIBMCmValidationSimpleConfig(versionLocator), | ||
Check: resource.ComposeAggregateTestCheckFunc( | ||
testAccCheckIBMCmValidationExists("ibm_cm_validation.cm_validation", conf), | ||
resource.TestCheckResourceAttr("ibm_cm_validation.cm_validation", "version_locator", versionLocator), | ||
), | ||
}, | ||
}, | ||
}) | ||
} | ||
|
||
func testAccCheckIBMCmValidationSimpleConfig(versionLocator string) string { | ||
return fmt.Sprintf(` | ||
resource "ibm_cm_validation" "cm_validation" { | ||
version_locator = "%s" | ||
revalidate_if_validated = true | ||
mark_version_consumable = false | ||
override_values = { | ||
name = "My TF" | ||
} | ||
environment_variables { | ||
name = "test" | ||
value = "test" | ||
secure = true | ||
} | ||
environment_variables { | ||
} | ||
} | ||
`, versionLocator) | ||
} | ||
|
||
func testAccCheckIBMCmValidationExists(n string, obj catalogmanagementv1.Version) resource.TestCheckFunc { | ||
|
||
return func(s *terraform.State) error { | ||
return nil | ||
} | ||
} | ||
|
||
func testAccCheckIBMCmValidationDestroy(s *terraform.State) error { | ||
return nil | ||
} |