Skip to content

Commit d608f5e

Browse files
committed
add getHello to identify server
Signed-off-by: zunda <zunda.dev@gmail.com>
1 parent 7404c92 commit d608f5e

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

.github/workflows/ci.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,6 @@ jobs:
3333
- name: Checkout
3434
uses: actions/checkout@v4
3535
- name: Test
36-
env:
37-
IS_VALKEY: ${{ matrix.database == 'valkey/valkey:latest' && 'true' || 'false' }}
3836
run: |
3937
swift test --enable-code-coverage
4038
- name: Convert coverage files

Tests/IntegrationTests/CommandIntegrationTests.swift

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ import Valkey
1616
@Suite("Command Integration Tests")
1717
struct CommandIntegratedTests {
1818
let valkeyHostname = ProcessInfo.processInfo.environment["VALKEY_HOSTNAME"] ?? "localhost"
19-
static let isValkey = ProcessInfo.processInfo.environment["IS_VALKEY"] == "true"
2019

2120
@available(valkeySwift 1.0, *)
2221
func withKey<Value>(connection: some ValkeyClientProtocol, _ operation: (ValkeyKey) async throws -> Value) async throws -> Value {
@@ -194,11 +193,20 @@ struct CommandIntegratedTests {
194193
}
195194

196195
@available(valkeySwift 1.0, *)
197-
@Test(.enabled(if: Self.isValkey))
196+
@Test
198197
func testSCRIPTfunctions() async throws {
199198
var logger = Logger(label: "Valkey")
200199
logger.logLevel = .trace
201200
try await withValkeyClient(.hostname(valkeyHostname, port: 6379), logger: logger) { client in
201+
let helloResponse = try await client.hello()
202+
let serverNameValue = try #require(helloResponse.first { $0.key.value == .bulkString(ByteBuffer(string: "server")) }?.value.value)
203+
let serverName: String? = if case .bulkString(let nameBuffer) = serverNameValue {
204+
String(buffer: nameBuffer)
205+
} else {
206+
nil
207+
}
208+
guard serverName == "valkey" else { return }
209+
202210
let sha1 = try await client.scriptLoad(
203211
script: "return redis.call(\"GET\", KEYS[1])"
204212
)

0 commit comments

Comments
 (0)