Skip to content

Commit d1aab90

Browse files
committed
skip test if api doesn't exist
1 parent 36a651b commit d1aab90

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

cloudstack/resource_cloudstack_cni_configuration_test.go

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ func TestAccCloudStackCniConfiguration_basic(t *testing.T) {
3232
var cniConfig cloudstack.UserData
3333

3434
resource.Test(t, resource.TestCase{
35-
PreCheck: func() { testAccPreCheck(t) },
35+
PreCheck: func() { testAccPreCheck(t); testAccPreCheckCniSupport(t) },
3636
Providers: testAccProviders,
3737
CheckDestroy: testAccCheckCloudStackCniConfigurationDestroy,
3838
Steps: []resource.TestStep{
@@ -140,3 +140,14 @@ resource "cloudstack_cni_configuration" "foo" {
140140
params = ["KUBERNETES_NODE_NAME", "CNI_MTU"]
141141
}
142142
`
143+
144+
func testAccPreCheckCniSupport(t *testing.T) {
145+
cs := testAccProvider.Meta().(*cloudstack.CloudStackClient)
146+
147+
// Try to list CNI configurations to check if the feature is available
148+
p := cs.Configuration.NewListCniConfigurationParams()
149+
_, err := cs.Configuration.ListCniConfiguration(p)
150+
if err != nil {
151+
t.Skipf("CNI configuration not supported in this CloudStack version (requires 4.21.0+): %v", err)
152+
}
153+
}

0 commit comments

Comments
 (0)