Skip to content

Commit d4c9881

Browse files
Move version check into PreCheck to fix unit tests
Moved the getCloudStackVersion() call from the test function body into the PreCheck function. This ensures the version check only runs during acceptance tests (when TF_ACC is set), not during unit tests. Previously, the version check would fail unit tests when CloudStack environment variables were not set. This follows the standard pattern where all environment-dependent setup happens in PreCheck functions, which are only called by the test framework during acceptance tests.
1 parent 827c08d commit d4c9881

1 file changed

Lines changed: 10 additions & 9 deletions

File tree

cloudstack/resource_cloudstack_loadbalancer_rule_test.go

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -54,18 +54,19 @@ func TestAccCloudStackLoadBalancerRule_basic(t *testing.T) {
5454
}
5555

5656
func TestAccCloudStackLoadBalancerRule_update(t *testing.T) {
57-
// Skip this test on CloudStack 4.22.0.0 due to a known simulator bug
58-
// that causes "530 Internal Server Error" when updating load balancer rules.
59-
// This bug does not exist in 4.20.1.0, 4.22.1.0+, or 4.23.0.0+.
60-
version := getCloudStackVersion(t)
61-
if version == "4.22.0.0" {
62-
t.Skip("Skipping TestAccCloudStackLoadBalancerRule_update on CloudStack 4.22.0.0 due to known simulator bug (Error 530: Internal Server Error)")
63-
}
64-
6557
var id string
6658

6759
resource.Test(t, resource.TestCase{
68-
PreCheck: func() { testAccPreCheck(t) },
60+
PreCheck: func() {
61+
testAccPreCheck(t)
62+
// Skip this test on CloudStack 4.22.0.0 due to a known simulator bug
63+
// that causes "530 Internal Server Error" when updating load balancer rules.
64+
// This bug does not exist in 4.20.1.0, 4.22.1.0+, or 4.23.0.0+.
65+
version := getCloudStackVersion(t)
66+
if version == "4.22.0.0" {
67+
t.Skip("Skipping TestAccCloudStackLoadBalancerRule_update on CloudStack 4.22.0.0 due to known simulator bug (Error 530: Internal Server Error)")
68+
}
69+
},
6970
Providers: testAccProviders,
7071
CheckDestroy: testAccCheckCloudStackLoadBalancerRuleDestroy,
7172
Steps: []resource.TestStep{

0 commit comments

Comments
 (0)