Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add some tests #4

Merged
merged 1 commit into from
Jun 9, 2018
Merged
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: 3 additions & 1 deletion Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ let package = Package(
],
targets: [
.target(name: "NIORedis", dependencies: [ "NIO", "NIOFoundationCompat" ]),
.target(name: "Redis", dependencies: [ "NIORedis" ])
.target(name: "Redis", dependencies: [ "NIORedis" ]),
.testTarget(name: "NIORedisTests", dependencies: [ "NIORedis"]),
.testTarget(name: "RedisTests", dependencies: [ "Redis"]),
]
)
9 changes: 9 additions & 0 deletions Tests/LinuxMain.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import XCTest

import NIORedisTests
import RedisTests

var tests = [XCTestCaseEntry]()
tests += NIORedisTests.allTests()
tests += RedisTests.allTests()
XCTMain(tests)
12 changes: 12 additions & 0 deletions Tests/NIORedisTests/RESPValueTests.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import XCTest
@testable import NIORedis

final class RESPValueTests: XCTestCase {
func testDescription() throws {
XCTAssert(String(describing: RESPValue(1)) == "1")
}

static var allTests = [
("testDescription", testDescription)
]
}
9 changes: 9 additions & 0 deletions Tests/NIORedisTests/XCTestManifests.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import XCTest

#if !os(macOS)
public func allTests() -> [XCTestCaseEntry] {
return [
testCase(RESPValueTests.allTests),
]
}
#endif
32 changes: 32 additions & 0 deletions Tests/RedisTests/RedisClientTests.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import XCTest
@testable import Redis
import NIO

final class RedisClientTests: XCTestCase {
func testCreateClientWithDefaultArguments() throws {
let redisClient = Redis.createClient()

XCTAssert(redisClient.options.hostname! == "127.0.0.1")
XCTAssert(redisClient.options.port == 6379)
XCTAssert(redisClient.options.password == nil)
XCTAssert(redisClient.options.database == nil)
}

func testCreateClientWithSpecifiedArguments() throws {
let eventLoop = MultiThreadedEventLoopGroup(numberOfThreads: 1).next()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is an eventLoopGroup, not an eventLoop.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ups, never mind :-)


let redisClient = Redis.createClient(port: 6380, host: "localhost", password: "password", db: 1, eventLoopGroup: eventLoop)

XCTAssert(redisClient.options.hostname! == "localhost")
XCTAssert(redisClient.options.port == 6380)
XCTAssert(redisClient.options.password == "password")
XCTAssert(redisClient.options.database == 1)
XCTAssert(redisClient.options.eventLoopGroup === eventLoop)
XCTAssert(redisClient.eventLoop === eventLoop)
}

static var allTests = [
("testCreateClientWithDefaultArguments", testCreateClientWithDefaultArguments),
("testCreateClientWithSpecifiedArguments", testCreateClientWithSpecifiedArguments),
]
}
9 changes: 9 additions & 0 deletions Tests/RedisTests/XCTestManifests.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import XCTest

#if !os(macOS)
public func allTests() -> [XCTestCaseEntry] {
return [
testCase(RedisClientTests.allTests),
]
}
#endif