Skip to content

Commit 585c284

Browse files
committed
Remove testing for Cluster API resources in GitLab 15.0
1 parent b5114fe commit 585c284

File tree

4 files changed

+38
-0
lines changed

4 files changed

+38
-0
lines changed

internal/provider/helper_test.go

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
package provider
55

66
import (
7+
"context"
78
"fmt"
89
"io"
910
"os"
@@ -98,6 +99,37 @@ func testAccCheckEE(t *testing.T) {
9899
}
99100
}
100101

102+
func testAccRequiresLessThan(t *testing.T, requiredMaxVersion string) {
103+
isLessThan, err := isGitLabVersionLessThan(context.TODO(), testGitlabClient, requiredMaxVersion)()
104+
if err != nil {
105+
t.Fatalf("Failed to fetch GitLab version: %+v", err)
106+
}
107+
108+
if !isLessThan {
109+
t.Skipf("This test is only valid for GitLab versions less than %s", requiredMaxVersion)
110+
}
111+
}
112+
113+
func testAccRequiresAtLeast(t *testing.T, requiredMinVersion string) {
114+
isAtLeast, err := isGitLabVersionAtLeast(context.TODO(), testGitlabClient, requiredMinVersion)()
115+
if err != nil {
116+
t.Fatalf("Failed to fetch GitLab version: %+v", err)
117+
}
118+
119+
if !isAtLeast {
120+
t.Skipf("This test is only valid for GitLab versions newer than %s", requiredMinVersion)
121+
}
122+
}
123+
124+
func testAccIsRunningAtLeast(t *testing.T, requiredMinVersion string) bool {
125+
isAtLeast, err := isGitLabVersionAtLeast(context.TODO(), testGitlabClient, requiredMinVersion)()
126+
if err != nil {
127+
t.Fatalf("Failed to fetch GitLab version: %+v", err)
128+
}
129+
130+
return isAtLeast
131+
}
132+
101133
// testAccCurrentUser is a test helper for getting the current user of the provided client.
102134
func testAccCurrentUser(t *testing.T) *gitlab.User {
103135
t.Helper()

internal/provider/resource_gitlab_group_cluster_test.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ func TestAccGitlabGroupCluster_basic(t *testing.T) {
1818
rInt := acctest.RandInt()
1919

2020
resource.Test(t, resource.TestCase{
21+
PreCheck: func() { testAccRequiresLessThan(t, "15.0") },
2122
ProviderFactories: providerFactories,
2223
CheckDestroy: testAccCheckGitlabGroupClusterDestroy,
2324
Steps: []resource.TestStep{
@@ -105,6 +106,7 @@ func TestAccGitlabGroupCluster_import(t *testing.T) {
105106
rInt := acctest.RandInt()
106107

107108
resource.Test(t, resource.TestCase{
109+
PreCheck: func() { testAccRequiresLessThan(t, "15.0") },
108110
ProviderFactories: providerFactories,
109111
CheckDestroy: testAccCheckGitlabGroupClusterDestroy,
110112
Steps: []resource.TestStep{

internal/provider/resource_gitlab_instance_cluster_test.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ func TestAccGitlabInstanceCluster_basic(t *testing.T) {
1919
rInt := acctest.RandInt()
2020

2121
resource.Test(t, resource.TestCase{
22+
PreCheck: func() { testAccRequiresLessThan(t, "15.0") },
2223
ProviderFactories: providerFactories,
2324
CheckDestroy: testAccCheckGitlabInstanceClusterDestroy,
2425
Steps: []resource.TestStep{
@@ -107,6 +108,7 @@ func TestAccGitlabInstanceCluster_import(t *testing.T) {
107108
rInt := acctest.RandInt()
108109

109110
resource.Test(t, resource.TestCase{
111+
PreCheck: func() { testAccRequiresLessThan(t, "15.0") },
110112
ProviderFactories: providerFactories,
111113
CheckDestroy: testAccCheckGitlabInstanceClusterDestroy,
112114
Steps: []resource.TestStep{

internal/provider/resource_gitlab_project_cluster_test.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ func TestAccGitlabProjectCluster_basic(t *testing.T) {
1818
rInt := acctest.RandInt()
1919

2020
resource.Test(t, resource.TestCase{
21+
PreCheck: func() { testAccRequiresLessThan(t, "15.0") },
2122
ProviderFactories: providerFactories,
2223
CheckDestroy: testAccCheckGitlabProjectClusterDestroy,
2324
Steps: []resource.TestStep{
@@ -107,6 +108,7 @@ func TestAccGitlabProjectCluster_import(t *testing.T) {
107108
rInt := acctest.RandInt()
108109

109110
resource.Test(t, resource.TestCase{
111+
PreCheck: func() { testAccRequiresLessThan(t, "15.0") },
110112
ProviderFactories: providerFactories,
111113
CheckDestroy: testAccCheckGitlabProjectClusterDestroy,
112114
Steps: []resource.TestStep{

0 commit comments

Comments
 (0)