Skip to content

Commit bd4cf78

Browse files
committed
Update unit test references for new type names and to cover more test cases
1 parent 1c0ee4f commit bd4cf78

File tree

5 files changed

+61
-37
lines changed

5 files changed

+61
-37
lines changed

Tests/NIORedisTests/Commands/BasicCommandsTests.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22
import XCTest
33

44
final class BasicCommandsTests: XCTestCase {
5-
private let redis = NIORedis(executionModel: .spawnThreads(1))
5+
private let redis = RedisDriver(executionModel: .spawnThreads(1))
66
deinit { try? redis.terminate() }
77

8-
private var connection: NIORedisConnection?
8+
private var connection: RedisConnection?
99

1010
override func setUp() {
1111
do {

Tests/NIORedisTests/NIORedisTests.swift

Lines changed: 0 additions & 27 deletions
This file was deleted.
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
@testable import NIORedis
2+
import XCTest
3+
4+
final class RedisDriverTests: XCTestCase {
5+
private var driver: RedisDriver!
6+
private var connection: RedisConnection!
7+
8+
override func setUp() {
9+
let driver = RedisDriver(executionModel: .spawnThreads(1))
10+
11+
guard let connection = try? driver.makeConnection().wait() else {
12+
return XCTFail("Failed to create a connection!")
13+
}
14+
15+
self.driver = driver
16+
self.connection = connection
17+
}
18+
19+
override func tearDown() {
20+
_ = connection.command("FLUSHALL")
21+
.then { _ in self.connection.close() }
22+
.map { _ in try? self.driver.terminate() }
23+
}
24+
25+
func test_makeConnection() {
26+
XCTAssertNoThrow(try driver.makeConnection().wait().close())
27+
}
28+
29+
func test_command_succeeds() throws {
30+
let result = try connection.command(
31+
"SADD",
32+
arguments: [.bulkString("key".convertedToData()), try 3.convertToRESP()
33+
]).wait()
34+
35+
XCTAssertNotNil(result.int)
36+
XCTAssertEqual(result.int, 1)
37+
}
38+
39+
func test_command_fails() {
40+
let command = connection.command("GET")
41+
42+
XCTAssertThrowsError(try command.wait())
43+
}
44+
45+
static var allTests = [
46+
("test_makeConnection", test_makeConnection),
47+
("test_command_succeeds", test_command_succeeds),
48+
("test_command_fails", test_command_fails),
49+
]
50+
}

Tests/NIORedisTests/NIORedisPipelineTests.swift renamed to Tests/NIORedisTests/RedisPipelineTests.swift

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
@testable import NIORedis
22
import XCTest
33

4-
final class NIORedisPipelineTests: XCTestCase {
5-
private var redis: NIORedis!
6-
private var connection: NIORedisConnection!
4+
final class RedisPipelineTests: XCTestCase {
5+
private var redis: RedisDriver!
6+
private var connection: RedisConnection!
77

88
override func setUp() {
9-
let redis = NIORedis(executionModel: .spawnThreads(2))
9+
let redis = RedisDriver(executionModel: .spawnThreads(2))
1010

1111
guard let connection = try? redis.makeConnection().wait() else {
1212
return XCTFail("Failed to create connection!")
@@ -30,10 +30,11 @@ final class NIORedisPipelineTests: XCTestCase {
3030
}
3131

3232
func test_executeFails() throws {
33-
let pipeline = try connection.makePipeline()
33+
let future = try connection.makePipeline()
3434
.enqueue(command: "GET")
35+
.execute()
3536

36-
XCTAssertThrowsError(try pipeline.execute().wait())
37+
XCTAssertThrowsError(try future.wait())
3738
}
3839

3940
func test_singleCommand() throws {

Tests/NIORedisTests/XCTestManifests.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,14 @@ import XCTest
33
#if !os(macOS)
44
public func allTests() -> [XCTestCaseEntry] {
55
return [
6-
testCase(NIORedisTests.allTests),
6+
testCase(RedisDriverTests.allTests),
77
testCase(RESPDecoderTests.allTests),
88
testCase(RESPDecoderParsingTests.allTests),
99
testCase(RESPDecoderByteToMessageDecoderTests.allTests),
1010
testCase(RESPEncoderTests.allTests),
1111
testCase(RESPEncoderParsingTests.allTests),
1212
testCase(BasicCommandsTests.allTests),
13-
testCase(NIORedisPipelineTests.allTests)
13+
testCase(RedisPipelineTests.allTests)
1414
]
1515
}
1616
#endif

0 commit comments

Comments
 (0)