Skip to content

Commit ce43dad

Browse files
committed
Split tests into two targets: Unit tests and Integration tests
Motivation: For users looking to contribute, and for those looking to validate the library, it was unclear what tests require an actual connection to a Redis instance in order to run. Modifications: Add a `RediStackIntegrationTests` that takes all tests that require a Redis instance in order to run. Result: Those looking to run just unit tests, or contribute new tests, can now directly point to a specific testTarget as defined in the Package manifest.
1 parent 1b4b5fa commit ce43dad

12 files changed

+178
-156
lines changed

Package.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ let package = Package(
2929
targets: [
3030
.target(name: "RediStack", dependencies: ["NIO", "Logging", "Metrics"]),
3131
.target(name: "RediStackTestUtils", dependencies: ["NIO", "RediStack"]),
32-
.testTarget(name: "RediStackTests", dependencies: ["RediStack", "NIO", "RediStackTestUtils"])
32+
.testTarget(name: "RediStackTests", dependencies: ["RediStack", "NIO", "RediStackTestUtils"]),
33+
.testTarget(name: "RediStackIntegrationTests", dependencies: ["RediStack", "NIO", "RediStackTestUtils"])
3334
]
3435
)

Tests/LinuxMain.swift

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

3+
import RediStackIntegrationTests
34
import RediStackTests
45

56
var tests = [XCTestCaseEntry]()
7+
tests += RediStackIntegrationTests.__allTests()
68
tests += RediStackTests.__allTests()
79

810
XCTMain(tests)
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Lines changed: 163 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,163 @@
1+
#if !canImport(ObjectiveC)
2+
import XCTest
3+
4+
extension BasicCommandsTests {
5+
// DO NOT MODIFY: This is autogenerated, use:
6+
// `swift test --generate-linuxmain`
7+
// to regenerate.
8+
static let __allTests__BasicCommandsTests = [
9+
("test_delete", test_delete),
10+
("test_echo", test_echo),
11+
("test_expire", test_expire),
12+
("test_ping", test_ping),
13+
("test_scan", test_scan),
14+
("test_select", test_select),
15+
("test_swapDatabase", test_swapDatabase),
16+
]
17+
}
18+
19+
extension HashCommandsTests {
20+
// DO NOT MODIFY: This is autogenerated, use:
21+
// `swift test --generate-linuxmain`
22+
// to regenerate.
23+
static let __allTests__HashCommandsTests = [
24+
("test_hdel", test_hdel),
25+
("test_hexists", test_hexists),
26+
("test_hgetall", test_hgetall),
27+
("test_hget", test_hget),
28+
("test_hincrby", test_hincrby),
29+
("test_hincrbyfloat", test_hincrbyfloat),
30+
("test_hkeys", test_hkeys),
31+
("test_hlen", test_hlen),
32+
("test_hmget", test_hmget),
33+
("test_hmset", test_hmset),
34+
("test_hscan", test_hscan),
35+
("test_hset", test_hset),
36+
("test_hsetnx", test_hsetnx),
37+
("test_hstrlen", test_hstrlen),
38+
("test_hvals", test_hvals),
39+
]
40+
}
41+
42+
extension ListCommandsTests {
43+
// DO NOT MODIFY: This is autogenerated, use:
44+
// `swift test --generate-linuxmain`
45+
// to regenerate.
46+
static let __allTests__ListCommandsTests = [
47+
("test_blpop", test_blpop),
48+
("test_brpop", test_brpop),
49+
("test_brpoplpush", test_brpoplpush),
50+
("test_lindex", test_lindex),
51+
("test_linsert", test_linsert),
52+
("test_llen", test_llen),
53+
("test_lpop", test_lpop),
54+
("test_lpush", test_lpush),
55+
("test_lpushx", test_lpushx),
56+
("test_lrange", test_lrange),
57+
("test_lrem", test_lrem),
58+
("test_lset", test_lset),
59+
("test_rpop", test_rpop),
60+
("test_rpoplpush", test_rpoplpush),
61+
("test_rpush", test_rpush),
62+
("test_rpushx", test_rpushx),
63+
]
64+
}
65+
66+
extension RedisConnectionTests {
67+
// DO NOT MODIFY: This is autogenerated, use:
68+
// `swift test --generate-linuxmain`
69+
// to regenerate.
70+
static let __allTests__RedisConnectionTests = [
71+
("test_callingCloseMultipleTimes", test_callingCloseMultipleTimes),
72+
("test_sendingCommandAfterClosing", test_sendingCommandAfterClosing),
73+
("test_unexpectedChannelClose", test_unexpectedChannelClose),
74+
]
75+
}
76+
77+
extension SetCommandsTests {
78+
// DO NOT MODIFY: This is autogenerated, use:
79+
// `swift test --generate-linuxmain`
80+
// to regenerate.
81+
static let __allTests__SetCommandsTests = [
82+
("test_sadd", test_sadd),
83+
("test_scard", test_scard),
84+
("test_sdiff", test_sdiff),
85+
("test_sdiffstore", test_sdiffstore),
86+
("test_sinter", test_sinter),
87+
("test_sinterstore", test_sinterstore),
88+
("test_sismember", test_sismember),
89+
("test_smembers", test_smembers),
90+
("test_smove", test_smove),
91+
("test_spop", test_spop),
92+
("test_srandmember", test_srandmember),
93+
("test_srem", test_srem),
94+
("test_sscan", test_sscan),
95+
("test_sunion", test_sunion),
96+
("test_sunionstore", test_sunionstore),
97+
]
98+
}
99+
100+
extension SortedSetCommandsTests {
101+
// DO NOT MODIFY: This is autogenerated, use:
102+
// `swift test --generate-linuxmain`
103+
// to regenerate.
104+
static let __allTests__SortedSetCommandsTests = [
105+
("test_bzpopmax", test_bzpopmax),
106+
("test_bzpopmin", test_bzpopmin),
107+
("test_zadd", test_zadd),
108+
("test_zcard", test_zcard),
109+
("test_zcount", test_zcount),
110+
("test_zincrby", test_zincrby),
111+
("test_zinterstore", test_zinterstore),
112+
("test_zlexcount", test_zlexcount),
113+
("test_zpopmax", test_zpopmax),
114+
("test_zpopmin", test_zpopmin),
115+
("test_zrange", test_zrange),
116+
("test_zrangebylex", test_zrangebylex),
117+
("test_zrangebyscore", test_zrangebyscore),
118+
("test_zrank", test_zrank),
119+
("test_zrem", test_zrem),
120+
("test_zremrangebylex", test_zremrangebylex),
121+
("test_zremrangebyrank", test_zremrangebyrank),
122+
("test_zremrangebyscore", test_zremrangebyscore),
123+
("test_zrevrange", test_zrevrange),
124+
("test_zrevrangebylex", test_zrevrangebylex),
125+
("test_zrevrangebyscore", test_zrevrangebyscore),
126+
("test_zrevrank", test_zrevrank),
127+
("test_zscan", test_zscan),
128+
("test_zscore", test_zscore),
129+
("test_zunionstore", test_zunionstore),
130+
]
131+
}
132+
133+
extension StringCommandsTests {
134+
// DO NOT MODIFY: This is autogenerated, use:
135+
// `swift test --generate-linuxmain`
136+
// to regenerate.
137+
static let __allTests__StringCommandsTests = [
138+
("test_append", test_append),
139+
("test_decrement", test_decrement),
140+
("test_decrementBy", test_decrementBy),
141+
("test_get", test_get),
142+
("test_increment", test_increment),
143+
("test_incrementBy", test_incrementBy),
144+
("test_incrementByFloat", test_incrementByFloat),
145+
("test_mget", test_mget),
146+
("test_mset", test_mset),
147+
("test_msetnx", test_msetnx),
148+
("test_set", test_set),
149+
]
150+
}
151+
152+
public func __allTests() -> [XCTestCaseEntry] {
153+
return [
154+
testCase(BasicCommandsTests.__allTests__BasicCommandsTests),
155+
testCase(HashCommandsTests.__allTests__HashCommandsTests),
156+
testCase(ListCommandsTests.__allTests__ListCommandsTests),
157+
testCase(RedisConnectionTests.__allTests__RedisConnectionTests),
158+
testCase(SetCommandsTests.__allTests__SetCommandsTests),
159+
testCase(SortedSetCommandsTests.__allTests__SortedSetCommandsTests),
160+
testCase(StringCommandsTests.__allTests__StringCommandsTests),
161+
]
162+
}
163+
#endif

0 commit comments

Comments
 (0)