Skip to content

Commit 1a55bd2

Browse files
authored
Merge pull request #4 from vkill/feature/add-tests
Add some tests
2 parents 35a408e + a31aca0 commit 1a55bd2

File tree

6 files changed

+74
-1
lines changed

6 files changed

+74
-1
lines changed

Package.swift

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ let package = Package(
1414
],
1515
targets: [
1616
.target(name: "NIORedis", dependencies: [ "NIO", "NIOFoundationCompat" ]),
17-
.target(name: "Redis", dependencies: [ "NIORedis" ])
17+
.target(name: "Redis", dependencies: [ "NIORedis" ]),
18+
.testTarget(name: "NIORedisTests", dependencies: [ "NIORedis"]),
19+
.testTarget(name: "RedisTests", dependencies: [ "Redis"]),
1820
]
1921
)

Tests/LinuxMain.swift

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import XCTest
2+
3+
import NIORedisTests
4+
import RedisTests
5+
6+
var tests = [XCTestCaseEntry]()
7+
tests += NIORedisTests.allTests()
8+
tests += RedisTests.allTests()
9+
XCTMain(tests)
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import XCTest
2+
@testable import NIORedis
3+
4+
final class RESPValueTests: XCTestCase {
5+
func testDescription() throws {
6+
XCTAssert(String(describing: RESPValue(1)) == "1")
7+
}
8+
9+
static var allTests = [
10+
("testDescription", testDescription)
11+
]
12+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import XCTest
2+
3+
#if !os(macOS)
4+
public func allTests() -> [XCTestCaseEntry] {
5+
return [
6+
testCase(RESPValueTests.allTests),
7+
]
8+
}
9+
#endif
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
import XCTest
2+
@testable import Redis
3+
import NIO
4+
5+
final class RedisClientTests: XCTestCase {
6+
func testCreateClientWithDefaultArguments() throws {
7+
let redisClient = Redis.createClient()
8+
9+
XCTAssert(redisClient.options.hostname! == "127.0.0.1")
10+
XCTAssert(redisClient.options.port == 6379)
11+
XCTAssert(redisClient.options.password == nil)
12+
XCTAssert(redisClient.options.database == nil)
13+
}
14+
15+
func testCreateClientWithSpecifiedArguments() throws {
16+
let eventLoop = MultiThreadedEventLoopGroup(numberOfThreads: 1).next()
17+
18+
let redisClient = Redis.createClient(port: 6380, host: "localhost", password: "password", db: 1, eventLoopGroup: eventLoop)
19+
20+
XCTAssert(redisClient.options.hostname! == "localhost")
21+
XCTAssert(redisClient.options.port == 6380)
22+
XCTAssert(redisClient.options.password == "password")
23+
XCTAssert(redisClient.options.database == 1)
24+
XCTAssert(redisClient.options.eventLoopGroup === eventLoop)
25+
XCTAssert(redisClient.eventLoop === eventLoop)
26+
}
27+
28+
static var allTests = [
29+
("testCreateClientWithDefaultArguments", testCreateClientWithDefaultArguments),
30+
("testCreateClientWithSpecifiedArguments", testCreateClientWithSpecifiedArguments),
31+
]
32+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import XCTest
2+
3+
#if !os(macOS)
4+
public func allTests() -> [XCTestCaseEntry] {
5+
return [
6+
testCase(RedisClientTests.allTests),
7+
]
8+
}
9+
#endif

0 commit comments

Comments
 (0)