Skip to content

Commit

Permalink
make it so that you can always get default values of manager
Browse files Browse the repository at this point in the history
this is so that we can create test factories that allow us to test the
default behaviour except for specific overrides
  • Loading branch information
lawrence-forooghian committed Sep 26, 2024
1 parent 0f7a58a commit e47096e
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 12 deletions.
8 changes: 4 additions & 4 deletions Sources/AblyChat/RoomLifecycleManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,15 @@ internal actor RoomLifecycleManager<Channel: RoomLifecycleContributorChannel> {

internal init(contributors: [Contributor], logger: InternalLogger, clock: SimpleClock) {
self.init(
current: .initialized,
current: nil,
contributors: contributors,
logger: logger,
clock: clock
)
}

#if DEBUG
internal init(testsOnly_current current: RoomLifecycle, contributors: [Contributor], logger: InternalLogger, clock: SimpleClock) {
internal init(testsOnly_current current: RoomLifecycle? = nil, contributors: [Contributor], logger: InternalLogger, clock: SimpleClock) {
self.init(
current: current,
contributors: contributors,
Expand All @@ -49,8 +49,8 @@ internal actor RoomLifecycleManager<Channel: RoomLifecycleContributorChannel> {
}
#endif

private init(current: RoomLifecycle, contributors: [Contributor], logger: InternalLogger, clock: SimpleClock) {
self.current = current
private init(current: RoomLifecycle?, contributors: [Contributor], logger: InternalLogger, clock: SimpleClock) {
self.current = current ?? .initialized
self.contributors = contributors
self.logger = logger
self.clock = clock
Expand Down
9 changes: 1 addition & 8 deletions Tests/AblyChatTests/RoomLifecycleManagerTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,7 @@ struct RoomLifecycleManagerTests {
}

private func createManager(
contributors: [RoomLifecycleManager<MockRoomLifecycleContributorChannel>.Contributor] = [],
clock: SimpleClock = MockSimpleClock()
) -> RoomLifecycleManager<MockRoomLifecycleContributorChannel> {
.init(contributors: contributors, logger: TestLogger(), clock: clock)
}

private func createManager(
forTestingWhatHappensWhenCurrentlyIn current: RoomLifecycle,
forTestingWhatHappensWhenCurrentlyIn current: RoomLifecycle? = nil,
contributors: [RoomLifecycleManager<MockRoomLifecycleContributorChannel>.Contributor] = [],
clock: SimpleClock = MockSimpleClock()
) -> RoomLifecycleManager<MockRoomLifecycleContributorChannel> {
Expand Down

0 comments on commit e47096e

Please sign in to comment.