Skip to content

Commit 01baeb9

Browse files
committed
Fixes according to review
1 parent 9e10e42 commit 01baeb9

File tree

3 files changed

+19
-15
lines changed

3 files changed

+19
-15
lines changed

Tests/AsyncAwait/ChatAsyncIntegrationTests.swift

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ class ChatAsyncIntegrationTests: BaseAsyncIntegrationTestCase {
4242
func testChatAsync_GetUsers() async throws {
4343
let user = try await chat.createUser(id: randomString())
4444
let secondUser = try await chat.createUser(id: randomString())
45-
let getUsersResponse = try await chat.getUsers(filter: "id LIKE 'swift-chat*'")
45+
let getUsersResponse = try await chat.getUsers(filter: "id LIKE '\(Constants.prefix)*'")
4646

4747
XCTAssertEqual(
4848
Set(getUsersResponse.users.map { $0.id }),
@@ -106,11 +106,11 @@ class ChatAsyncIntegrationTests: BaseAsyncIntegrationTestCase {
106106
let user2 = try await chat.createUser(id: randomString(), name: "User2")
107107
let user3 = try await chat.createUser(id: randomString(), name: "User3")
108108

109-
let firstPageResponse = try await chat.getUsers(filter: "id LIKE 'swift-chat*'", limit: 2)
110-
let secondPageResponse = try await chat.getUsers(filter: "id LIKE 'swift-chat*'", page: firstPageResponse.page)
109+
let firstPageResponse = try await chat.getUsers(filter: "id LIKE '\(Constants.prefix)*'", limit: 2)
110+
let secondPageResponse = try await chat.getUsers(filter: "id LIKE '\(Constants.prefix)*'", page: firstPageResponse.page)
111111

112-
XCTAssertTrue(firstPageResponse.users.count == 2)
113-
XCTAssertTrue(secondPageResponse.users.count == 1)
112+
XCTAssertEqual(firstPageResponse.users.count, 2)
113+
XCTAssertEqual(secondPageResponse.users.count, 1)
114114

115115
let idsFromFirstPage = Set(firstPageResponse.users.map { $0.id })
116116
let idsFromSecondPage = Set(secondPageResponse.users.map { $0.id })
@@ -209,7 +209,7 @@ class ChatAsyncIntegrationTests: BaseAsyncIntegrationTestCase {
209209
func testChatAsync_GetChannels() async throws {
210210
let channel = try await chat.createChannel(id: randomString())
211211
let secondChannel = try await chat.createChannel(id: randomString())
212-
let getChannelsResponse = try await chat.getChannels(filter: "id LIKE 'swift-chat*'")
212+
let getChannelsResponse = try await chat.getChannels(filter: "id LIKE '\(Constants.prefix)*'")
213213

214214
XCTAssertEqual(
215215
Set(getChannelsResponse.channels.map { $0.id }),
@@ -265,11 +265,11 @@ class ChatAsyncIntegrationTests: BaseAsyncIntegrationTestCase {
265265
let channel2 = try await chat.createChannel(id: randomString(), name: "Channel2")
266266
let channel3 = try await chat.createChannel(id: randomString(), name: "Channel3")
267267

268-
let firstPageResponse = try await chat.getChannels(filter: "id LIKE 'swift-chat*'", limit: 2)
269-
let secondPageResponse = try await chat.getChannels(filter: "id LIKE 'swift-chat*'", page: firstPageResponse.page)
268+
let firstPageResponse = try await chat.getChannels(filter: "id LIKE '\(Constants.prefix)*'", limit: 2)
269+
let secondPageResponse = try await chat.getChannels(filter: "id LIKE '\(Constants.prefix)*'", page: firstPageResponse.page)
270270

271-
XCTAssertTrue(firstPageResponse.channels.count == 2)
272-
XCTAssertTrue(secondPageResponse.channels.count == 1)
271+
XCTAssertEqual(firstPageResponse.channels.count, 2)
272+
XCTAssertEqual(secondPageResponse.channels.count, 1)
273273

274274
let idsFromFirstPage = Set(firstPageResponse.channels.map { $0.id })
275275
let idsFromSecondPage = Set(secondPageResponse.channels.map { $0.id })

Tests/BaseIntegrationTestCase.swift

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,17 @@ import PubNubSDK
1212
import PubNubSwiftChatSDK
1313
import XCTest
1414

15+
enum Constants {
16+
static let prefix = "swift-chat"
17+
}
18+
1519
class BaseIntegrationTestCase: XCTestCase {
1620
lazy var chat: ChatImpl! = IntegrationTestCaseConfiguration.createChatObject()
1721
}
1822

1923
extension BaseIntegrationTestCase {
2024
func randomString(length: Int = 6, withPrefix: Bool = true) -> String {
2125
let randomStr = RandomStringGenerator().randomString(length: length)
22-
return withPrefix ? "swift-chat" + randomStr : randomStr
26+
return withPrefix ? Constants.prefix + randomStr : randomStr
2327
}
2428
}

Tests/ChatIntegrationTests.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ class ChatIntegrationTests: BaseClosureIntegrationTestCase {
6767
}
6868
let getUsersResponse = try awaitResultValue {
6969
chat.getUsers(
70-
filter: "id LIKE 'swift-chat*'",
70+
filter: "id LIKE '\(Constants.prefix)*'",
7171
completion: $0
7272
)
7373
}
@@ -374,7 +374,7 @@ class ChatIntegrationTests: BaseClosureIntegrationTestCase {
374374

375375
let retrievedChannels = try awaitResultValue {
376376
chat.getChannels(
377-
filter: "id LIKE 'swift-chat*'",
377+
filter: "id LIKE '\(Constants.prefix)*'",
378378
completion: $0
379379
)
380380
}
@@ -425,15 +425,15 @@ class ChatIntegrationTests: BaseClosureIntegrationTestCase {
425425

426426
let firstPageResponse = try awaitResultValue {
427427
chat.getChannels(
428-
filter: "id LIKE 'swift-chat*'",
428+
filter: "id LIKE '\(Constants.prefix)*'",
429429
limit: 2,
430430
completion: $0
431431
)
432432
}
433433

434434
let secondPageResponse = try awaitResultValue {
435435
chat.getChannels(
436-
filter: "id LIKE 'swift-chat*'",
436+
filter: "id LIKE '\(Constants.prefix)*'",
437437
page: firstPageResponse.page,
438438
completion: $0
439439
)

0 commit comments

Comments
 (0)