From f4454ee99300078b714efc8f4b3d6e59635f9021 Mon Sep 17 00:00:00 2001 From: dblock Date: Tue, 20 Aug 2024 08:47:51 -0400 Subject: [PATCH] Fix: skip if below test cases. Signed-off-by: dblock --- internal/test/helper.go | 2 +- opensearchapi/api_cat_test.go | 4 ++-- opensearchapi/api_cluster_test.go | 2 +- plugins/security/api_ssl_test.go | 4 ++-- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/internal/test/helper.go b/internal/test/helper.go index ebea0ad98..1cd2780f5 100644 --- a/internal/test/helper.go +++ b/internal/test/helper.go @@ -105,7 +105,7 @@ func SkipIfBelowVersion(t *testing.T, client *opensearchapi.Client, majorVersion t.Helper() major, patch, _, err := GetVersion(client) assert.Nil(t, err) - if major <= majorVersion && patch <= patchVersion { + if major < majorVersion || (major == majorVersion && patch < patchVersion) { t.Skipf("Skiping %s as version %d.%d.x does not support this endpoint", testName, major, patch) } } diff --git a/opensearchapi/api_cat_test.go b/opensearchapi/api_cat_test.go index 223ddecd9..d8b02ef7a 100644 --- a/opensearchapi/api_cat_test.go +++ b/opensearchapi/api_cat_test.go @@ -366,7 +366,7 @@ func TestCatClient(t *testing.T) { for catType, value := range testCases { t.Run(catType, func(t *testing.T) { if catType == "ClusterManager" { - ostest.SkipIfBelowVersion(t, client, 1, 3, catType) + ostest.SkipIfBelowVersion(t, client, 2, 0, catType) } for _, testCase := range value { t.Run(testCase.Name, func(t *testing.T) { @@ -399,7 +399,7 @@ func TestCatClient(t *testing.T) { ostest.CompareRawJSONwithParsedJSON(t, resp.Allocations, resp.Inspect().Response) }) t.Run("ClusterManager", func(t *testing.T) { - ostest.SkipIfBelowVersion(t, client, 1, 3, "ClusterManager") + ostest.SkipIfBelowVersion(t, client, 2, 0, "ClusterManager") resp, err := client.Cat.ClusterManager(nil, nil) assert.Nil(t, err) assert.NotNil(t, resp) diff --git a/opensearchapi/api_cluster_test.go b/opensearchapi/api_cluster_test.go index a2c65085b..831a1bd8a 100644 --- a/opensearchapi/api_cluster_test.go +++ b/opensearchapi/api_cluster_test.go @@ -230,7 +230,7 @@ func TestClusterClient(t *testing.T) { for catType, value := range testCases { t.Run(catType, func(t *testing.T) { if strings.Contains(catType, "Decommission") { - ostest.SkipIfBelowVersion(t, client, 2, 3, catType) + ostest.SkipIfBelowVersion(t, client, 2, 4, catType) } for _, testCase := range value { t.Run(testCase.Name, func(t *testing.T) { diff --git a/plugins/security/api_ssl_test.go b/plugins/security/api_ssl_test.go index ea89ea25e..92ee27d1a 100644 --- a/plugins/security/api_ssl_test.go +++ b/plugins/security/api_ssl_test.go @@ -30,7 +30,7 @@ func TestSSLClient(t *testing.T) { osAPIclient, err := ostest.NewClient() require.Nil(t, err) - ostest.SkipIfBelowVersion(t, osAPIclient, 1, 3, "SSLClient") + ostest.SkipIfBelowVersion(t, osAPIclient, 2, 0, "SSLClient") clientTLSCert, err := tls.LoadX509KeyPair("../../admin.pem", "../../admin.key") require.Nil(t, err) @@ -114,7 +114,7 @@ func TestSSLClient(t *testing.T) { for _, testCase := range value.Tests { t.Run(testCase.Name, func(t *testing.T) { if strings.HasSuffix(value.Name, "Reload") && strings.Contains(testCase.Name, "request") { - ostest.SkipIfBelowVersion(t, osAPIclient, 2, 7, value.Name) + ostest.SkipIfBelowVersion(t, osAPIclient, 2, 8, value.Name) } res, err := testCase.Results() if testCase.Name == "inspect" {