Skip to content

Commit 3a31338

Browse files
committed
test only for 8.4
1 parent 9131fcb commit 3a31338

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

digest_test.go

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,35 @@ package redis_test
22

33
import (
44
"context"
5+
"os"
6+
"strconv"
7+
"strings"
58
"testing"
69

710
"github.com/redis/go-redis/v9"
811
)
912

13+
func init() {
14+
// Initialize RedisVersion from environment variable for regular Go tests
15+
// (Ginkgo tests initialize this in BeforeSuite)
16+
if version := os.Getenv("REDIS_VERSION"); version != "" {
17+
if v, err := strconv.ParseFloat(strings.Trim(version, "\""), 64); err == nil && v > 0 {
18+
RedisVersion = v
19+
}
20+
}
21+
}
22+
23+
// skipIfRedisBelow84 checks if Redis version is below 8.4 and skips the test if so
24+
func skipIfRedisBelow84(t *testing.T) {
25+
if RedisVersion < 8.4 {
26+
t.Skipf("Skipping test: Redis version %.1f < 8.4 (DIGEST command requires Redis 8.4+)", RedisVersion)
27+
}
28+
}
29+
1030
// TestDigestBasic validates that the Digest command returns a uint64 value
1131
func TestDigestBasic(t *testing.T) {
32+
skipIfRedisBelow84(t)
33+
1234
ctx := context.Background()
1335
client := redis.NewClient(&redis.Options{
1436
Addr: "localhost:6379",
@@ -51,6 +73,8 @@ func TestDigestBasic(t *testing.T) {
5173

5274
// TestSetIFDEQWithDigest validates the SetIFDEQ command works with digests
5375
func TestSetIFDEQWithDigest(t *testing.T) {
76+
skipIfRedisBelow84(t)
77+
5478
ctx := context.Background()
5579
client := redis.NewClient(&redis.Options{
5680
Addr: "localhost:6379",
@@ -113,6 +137,8 @@ func TestSetIFDEQWithDigest(t *testing.T) {
113137

114138
// TestSetIFDNEWithDigest validates the SetIFDNE command works with digests
115139
func TestSetIFDNEWithDigest(t *testing.T) {
140+
skipIfRedisBelow84(t)
141+
116142
ctx := context.Background()
117143
client := redis.NewClient(&redis.Options{
118144
Addr: "localhost:6379",
@@ -175,6 +201,8 @@ func TestSetIFDNEWithDigest(t *testing.T) {
175201

176202
// TestDelExArgsWithDigest validates DelExArgs works with digest matching
177203
func TestDelExArgsWithDigest(t *testing.T) {
204+
skipIfRedisBelow84(t)
205+
178206
ctx := context.Background()
179207
client := redis.NewClient(&redis.Options{
180208
Addr: "localhost:6379",

0 commit comments

Comments
 (0)