Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Sources/RediStack/Commands/SortedSetCommands.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
//
// This source file is part of the RediStack open source project
//
// Copyright (c) 2019-2022 Apple Inc. and the RediStack project authors
// Copyright (c) 2019-2026 Apple Inc. and the RediStack project authors
// Licensed under Apache License v2.0
//
// See LICENSE.txt for license information
Expand Down Expand Up @@ -611,7 +611,7 @@ extension RedisClient {

return send(command: command, with: args)
.tryConverting(to: [RESPValue].self)
.flatMapThrowing { try Self._mapSortedSetResponse($0, scoreIsFirst: true) }
.flatMapThrowing { try Self._mapSortedSetResponse($0, scoreIsFirst: false) }
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
//
// This source file is part of the RediStack open source project
//
// Copyright (c) 2019-2022 Apple Inc. and the RediStack project authors
// Copyright (c) 2019-2026 Apple Inc. and the RediStack project authors
// Licensed under Apache License v2.0
//
// See LICENSE.txt for license information
Expand Down Expand Up @@ -234,6 +234,36 @@ final class SortedSetCommandsTests: RediStackIntegrationTestCase {
XCTAssertEqual(result, .timedOut)
}

func test_zpopmin_nonNumericMembers() throws {
_ = try connection.zadd([("lowest", -2.5), ("middle", 0.25), ("highest", 9.75)], to: #function).wait()

let first = try XCTUnwrap(connection.zpopmin(from: #function).wait())
XCTAssertEqual(first.0.string, "lowest")
XCTAssertEqual(first.1, -2.5)

let remaining = try connection.zpopmin(from: #function, max: 3).wait()
XCTAssertEqual(remaining.map { $0.0.string }, ["middle", "highest"])
XCTAssertEqual(remaining.map { $0.1 }, [0.25, 9.75])

XCTAssertNil(try connection.zpopmin(from: #function).wait())
XCTAssertTrue(try connection.zpopmin(from: #function, max: 3).wait().isEmpty)
}

func test_zpopmax_nonNumericMembers() throws {
_ = try connection.zadd([("lowest", -2.5), ("middle", 0.25), ("highest", 9.75)], to: #function).wait()

let first = try XCTUnwrap(connection.zpopmax(from: #function).wait())
XCTAssertEqual(first.0.string, "highest")
XCTAssertEqual(first.1, 9.75)

let remaining = try connection.zpopmax(from: #function, max: 3).wait()
XCTAssertEqual(remaining.map { $0.0.string }, ["middle", "lowest"])
XCTAssertEqual(remaining.map { $0.1 }, [0.25, -2.5])

XCTAssertNil(try connection.zpopmax(from: #function).wait())
XCTAssertTrue(try connection.zpopmax(from: #function, max: 3).wait().isEmpty)
}

func test_zincrby() throws {
var score = try connection.zincrby(3_00_1398.328923, element: 1, in: key).wait()
XCTAssertEqual(score, 3_001_399.328923)
Expand Down