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

[ECO-4936] Implement the ability to attach and detach a room #35

Merged
merged 2 commits into from
Sep 3, 2024

Conversation

lawrence-forooghian
Copy link
Collaborator

@lawrence-forooghian lawrence-forooghian commented Sep 2, 2024

Based on the simplified requirements described in #19. This doesn’t include the emission of a room status change; will do that in a separate PR.

Summary by CodeRabbit

  • New Features

    • Introduced a new mock implementation for real-time channels, enhancing testing capabilities.
    • Added asynchronous methods for attaching and detaching channels, improving usability within Swift's concurrency model.
    • Implemented new protocols for real-time client interactions, streamlining channel management.
  • Bug Fixes

    • Improved error handling in the attach and detach methods to ensure consistent behavior during failures.
  • Tests

    • Added unit tests for the DefaultRoom class to validate channel attachment and detachment functionality.

Copy link

coderabbitai bot commented Sep 2, 2024

Walkthrough

The changes involve significant updates to the Ably Chat SDK, including the introduction of new protocols for real-time client functionality, asynchronous methods for channel management, and mock implementations for testing. These updates enhance the structure and flexibility of the SDK, aligning it with modern Swift concurrency practices and improving the testing framework.

Changes

Files Change Summary
Example/AblyChatExample/Mocks/MockRealtime.swift, Tests/AblyChatTests/Mocks/MockRealtime.swift Updated MockRealtime to conform to RealtimeClientProtocol, added channels property, modified initializers, and introduced a new convenience initializer. Enhanced configurability for testing.
Sources/AblyChat/AblyCocoaExtensions/Ably+Concurrency.swift Added asynchronous methods attachAsync() and detachAsync() to ARTRealtimeChannelProtocol for improved concurrency integration.
Sources/AblyChat/AblyCocoaExtensions/Ably+Dependencies.swift Introduced extensions to ARTRealtime, ARTRealtimeChannels, and ARTRealtimeChannel to conform to new protocols, ensuring compatibility with concurrency and addressing compiler warnings.
Sources/AblyChat/ChatClient.swift Changed RealtimeClient type alias from any(ARTRealtimeProtocol & Sendable) to any RealtimeClientProtocol, impacting type usage throughout the codebase.
Sources/AblyChat/Dependencies.swift Defined new protocols: RealtimeClientProtocol, RealtimeChannelsProtocol, and RealtimeChannelProtocol to standardize real-time client interactions and channel management.
Sources/AblyChat/Room.swift Introduced a private channels() method in DefaultRoom to dynamically manage channel attachment and detachment, replacing previous unimplemented logic.
Tests/AblyChatTests/DefaultRoomTests.swift Added unit tests for attach and detach methods in DefaultRoom, ensuring correct functionality with mock channels and handling of success and failure scenarios.
Tests/AblyChatTests/Mocks/MockChannels.swift Implemented MockChannels class with methods to manage mock channels for testing, including get, exists, and release.
Tests/AblyChatTests/Mocks/MockRealtimeChannel.swift Created MockRealtimeChannel class to simulate real-time channel behavior for testing, including attach and detach methods with configurable outcomes.

Assessment against linked issues

Objective Addressed Explanation
Chat room skeleton (ECO-4936)

🐇 In the meadow, I hop with glee,
New channels and protocols, oh what a spree!
Async methods dance in the light,
Testing is easier, everything feels right!
With mocks in hand, we leap and bound,
In the world of code, joy is found! 🌼

Tip

We have updated our review workflow to use the Anthropic's Claude family of models. Please share any feedback in the discussion post on our Discord.


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

Share
Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@lawrence-forooghian lawrence-forooghian marked this pull request as ready for review September 2, 2024 13:35
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

Outside diff range, codebase verification and nitpick comments (2)
Sources/AblyChat/Room.swift (2)

68-71: The attach() method is implemented correctly, but consider handling errors.

The method now attaches to all the channels associated with the room, which is the expected behavior. However, it doesn't handle any errors that may be thrown by the attachAsync() method.

Consider handling the errors and providing appropriate feedback to the user. For example:

public func attach() async throws {
    do {
        for channel in channels() {
            try await channel.attachAsync()
        }
    } catch {
        // Handle the error and provide feedback to the user
        print("Failed to attach to the room: \(error)")
        throw error
    }
}

74-77: The detach() method is implemented correctly, but consider handling errors.

The method now detaches from all the channels associated with the room, which is the expected behavior. However, it doesn't handle any errors that may be thrown by the detachAsync() method.

Consider handling the errors and providing appropriate feedback to the user. For example:

public func detach() async throws {
    do {
        for channel in channels() {
            try await channel.detachAsync()
        }
    } catch {
        // Handle the error and provide feedback to the user
        print("Failed to detach from the room: \(error)")
        throw error
    }
}
Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 0e9f703 and 4198c7f.

Files selected for processing (10)
  • Example/AblyChatExample/Mocks/MockRealtime.swift (2 hunks)
  • Sources/AblyChat/AblyCocoaExtensions/Ably+Concurrency.swift (1 hunks)
  • Sources/AblyChat/AblyCocoaExtensions/Ably+Dependencies.swift (1 hunks)
  • Sources/AblyChat/ChatClient.swift (1 hunks)
  • Sources/AblyChat/Dependencies.swift (1 hunks)
  • Sources/AblyChat/Room.swift (1 hunks)
  • Tests/AblyChatTests/DefaultRoomTests.swift (1 hunks)
  • Tests/AblyChatTests/Mocks/MockChannels.swift (1 hunks)
  • Tests/AblyChatTests/Mocks/MockRealtime.swift (2 hunks)
  • Tests/AblyChatTests/Mocks/MockRealtimeChannel.swift (1 hunks)
Additional comments not posted (26)
Tests/AblyChatTests/Mocks/MockChannels.swift (1)

1-30: LGTM!

The MockChannels class is a mock implementation of the RealtimeChannelsProtocol protocol and is used for testing purposes. The class is implemented correctly and follows the expected behavior of a mock class.

The code changes are approved.

Sources/AblyChat/AblyCocoaExtensions/Ably+Concurrency.swift (2)

7-17: LGTM!

The attachAsync method is correctly implemented and follows the best practices for converting completion handler based methods to async/await methods. The error handling is also done correctly.


19-29: LGTM!

The detachAsync method is correctly implemented and follows the best practices for converting completion handler based methods to async/await methods. The error handling is also done correctly.

Sources/AblyChat/AblyCocoaExtensions/Ably+Dependencies.swift (3)

5-12: LGTM!

The code changes in the Swift 6 conditional compilation block are approved for the following reasons:

  • The use of @retroactive is justified and explained clearly in the comment.
  • The use of @unchecked Sendable is consistent with the TODO comment.
  • The extensions conform to the necessary protocols.

13-18: LGTM!

The code changes in the Swift 5 conditional compilation block are approved for the following reasons:

  • The extensions conform to the necessary protocols.
  • The use of @unchecked Sendable is consistent with the TODO comment.

3-3: Acknowledge the TODO and suggest creating a follow-up issue.

The TODO comment indicates that the @unchecked Sendable attribute should be removed once the referenced issue in the Ably Cocoa library is resolved.

Consider creating a follow-up issue in this repository to track the removal of the attribute once the Ably Cocoa issue is resolved. This will help ensure that the TODO is not forgotten. Do you want me to open a GitHub issue for this?

Skipped due to learnings
Learnt from: lawrence-forooghian
PR: ably-labs/ably-chat-swift#9
File: Sources/AblyChat/Metadata.swift:1-2
Timestamp: 2024-08-28T12:07:31.704Z
Learning: When reviewing code, avoid commenting on TODOs that already have a linked GitHub issue, as per the user's preference.
Sources/AblyChat/Dependencies.swift (3)

6-11: The RealtimeClientProtocol is well-defined.

  • It clearly expresses the requirements of the Ably realtime client.
  • The comments provide useful context about the challenges faced while trying to add the channels property to ARTRealtimeProtocol.
  • The Sendable conformance is a good practice for concurrency safety.

14-19: The RealtimeChannelsProtocol is well-defined.

  • It clearly expresses the requirements of the object returned by RealtimeClientProtocol.channels.
  • The comments provide useful context about the missing get(_:) method in ARTRealtimeChannelsProtocol.
  • The Sendable conformance is a good practice for concurrency safety.

22-22: The RealtimeChannelProtocol is well-defined.

  • It expresses the requirements of the object returned by RealtimeChannelsProtocol.get(_:).
  • The Sendable conformance is a good practice for concurrency safety.
Sources/AblyChat/ChatClient.swift (1)

11-11: Verify the impact of changing the RealtimeClient type alias.

The change from any(ARTRealtimeProtocol & Sendable) to any RealtimeClientProtocol may have implications throughout the codebase. Please ensure that:

  1. All instances of RealtimeClient are still created and utilized correctly with the new type alias.
  2. The RealtimeClientProtocol provides all the necessary functionality and type safety that was previously provided by ARTRealtimeProtocol.
  3. Removing the Sendable protocol from the type alias does not introduce any concurrency or thread safety issues.

Run the following script to verify the usage of RealtimeClient and RealtimeClientProtocol:

Verification successful

Verification successful: The change to RealtimeClient type alias is consistent and maintains necessary protocol conformance.

The change from any(ARTRealtimeProtocol & Sendable) to any RealtimeClientProtocol does not introduce issues, as RealtimeClientProtocol still includes both ARTRealtimeProtocol and Sendable. The usage of RealtimeClient across the codebase is consistent with the new type alias, and no concurrency or thread safety issues are introduced.

  • RealtimeClientProtocol provides all necessary functionality and type safety.
  • The Sendable protocol is still part of RealtimeClientProtocol.
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the usage of `RealtimeClient` and `RealtimeClientProtocol`.

# Test 1: Search for the usage of `RealtimeClient`. Expect: Only occurrences with the new type alias.
rg --type swift -A 5 $'RealtimeClient'

# Test 2: Search for the usage of `RealtimeClientProtocol`. Expect: Occurrences in the protocol definition and the type alias.
rg --type swift -A 5 $'RealtimeClientProtocol'

# Test 3: Search for the usage of `ARTRealtimeProtocol`. Expect: No occurrences.
rg --type swift -A 5 $'ARTRealtimeProtocol'

Length of output: 12997

Tests/AblyChatTests/Mocks/MockRealtime.swift (5)

15-17: LGTM!

The initialization of the channels property in the initializer is appropriate and aligns with the introduction of the new property.


19-21: LGTM!

The initialization of the channels property is appropriate and consistent with the other initializers.


27-29: LGTM!

The new convenience initializer enhances the flexibility of the mock implementation by allowing the creation of instances with a specified set of channels. This is beneficial for testing scenarios.


38-39: LGTM!

The changes to the create method align with the introduction of the new initializer and provide a convenient way to create instances of MockRealtime with custom channel setups. This improves the usability of the mock class in testing scenarios.


6-6: Verify the impact of the protocol change on the mock implementation.

The class now conforms to RealtimeClientProtocol instead of ARTRealtimeProtocol. Ensure that the mock implementation aligns with the new protocol requirements and provides the necessary functionality for testing purposes.

Run the following script to verify the protocol conformance:

Verification successful

Verification successful: Protocol conformance is correctly implemented.

The MockRealtime class now conforms to RealtimeClientProtocol, which extends ARTRealtimeProtocol. This ensures that all necessary protocol requirements are met. The change aligns with the new protocol design without impacting the mock implementation's functionality.

  • RealtimeClientProtocol extends ARTRealtimeProtocol and Sendable.
  • MockRealtime conforms to RealtimeClientProtocol and Sendable.
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the protocol conformance of `MockRealtime`.

# Test: Search for the protocol declaration. Expect: `RealtimeClientProtocol` declaration.
rg --type swift $'protocol RealtimeClientProtocol'

# Test: Search for the `MockRealtime` declaration. Expect: Conformance to `RealtimeClientProtocol`.
rg --type swift $'final class MockRealtime: .*, RealtimeClientProtocol'

Length of output: 468

Sources/AblyChat/Room.swift (1)

58-66: LGTM!

The channels() method is implemented correctly and follows the best practices.

Tests/AblyChatTests/DefaultRoomTests.swift (4)

6-28: LGTM!

The test setup and assertions for verifying the behavior of the attach method when all channels succeed look good.


30-59: LGTM!

The test setup and assertions for verifying the behavior of the attach method when one of the channels fails look good.


61-83: LGTM!

The test setup and assertions for verifying the behavior of the detach method when all channels succeed look good.


85-114: LGTM!

The test setup and assertions for verifying the behavior of the detach method when one of the channels fails look good.

Tests/AblyChatTests/Mocks/MockRealtimeChannel.swift (4)

4-221: The mock implementation of RealtimeChannelProtocol looks good overall.

The MockRealtimeChannel class provides a way to mock the behavior of a real-time channel for testing purposes. It has properties to store the channel name, attach result, and detach result, and methods to mock the behavior of attaching and detaching from a channel.


18-43: The Counter class is a useful utility for keeping track of the number of times a method is called in a thread-safe manner.

The implementation looks good and thread-safe. It uses a lock to ensure thread safety.


79-87: The attach(_:) method looks good.

It correctly increments the attachCallCounter and performs the attach callback based on the attachResult property. The fatal error is appropriate as the attachResult must be set before calling the method for the mock to work correctly.


97-105: The detach(_:) method looks good.

It correctly increments the detachCallCounter and performs the detach callback based on the detachResult property. The fatal error is appropriate as the detachResult must be set before calling the method for the mock to work correctly.

Example/AblyChatExample/Mocks/MockRealtime.swift (2)

16-174: The addition of the Channels class and its nested Channel class looks good.

The Channels class provides a mock implementation for channels functionality by conforming to RealtimeChannelsProtocol. The nested Channel class, conforming to RealtimeChannelProtocol, provides a way to create channel instances.

The unimplemented methods throwing fatal errors are acceptable for a mock implementation as they serve as placeholders for future functionality.


2-2: Verify the consistency of the protocol change across the codebase.

The class declaration has been updated to conform to RealtimeClientProtocol instead of ARTRealtimeProtocol. Ensure that this change is consistently applied across the codebase and doesn't break any existing functionality.

Run the following script to verify the protocol usage:

The addition of the channels property looks good.

The channels property of type Channels has been added. The unimplemented methods throwing fatal errors are acceptable for a mock implementation.

Also applies to: 5-5, 14-14

Copy link
Collaborator

@maratal maratal left a comment

Choose a reason for hiding this comment

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

Some questions

Example/AblyChatExample/Mocks/MockRealtime.swift Outdated Show resolved Hide resolved
Sources/AblyChat/Dependencies.swift Outdated Show resolved Hide resolved
Sources/AblyChat/Room.swift Show resolved Hide resolved
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 4198c7f and 21da342.

Files selected for processing (10)
  • Example/AblyChatExample/Mocks/MockRealtime.swift (2 hunks)
  • Sources/AblyChat/AblyCocoaExtensions/Ably+Concurrency.swift (1 hunks)
  • Sources/AblyChat/AblyCocoaExtensions/Ably+Dependencies.swift (1 hunks)
  • Sources/AblyChat/ChatClient.swift (1 hunks)
  • Sources/AblyChat/Dependencies.swift (1 hunks)
  • Sources/AblyChat/Room.swift (1 hunks)
  • Tests/AblyChatTests/DefaultRoomTests.swift (1 hunks)
  • Tests/AblyChatTests/Mocks/MockChannels.swift (1 hunks)
  • Tests/AblyChatTests/Mocks/MockRealtime.swift (2 hunks)
  • Tests/AblyChatTests/Mocks/MockRealtimeChannel.swift (1 hunks)
Files skipped from review as they are similar to previous changes (8)
  • Sources/AblyChat/AblyCocoaExtensions/Ably+Concurrency.swift
  • Sources/AblyChat/AblyCocoaExtensions/Ably+Dependencies.swift
  • Sources/AblyChat/ChatClient.swift
  • Sources/AblyChat/Dependencies.swift
  • Sources/AblyChat/Room.swift
  • Tests/AblyChatTests/DefaultRoomTests.swift
  • Tests/AblyChatTests/Mocks/MockChannels.swift
  • Tests/AblyChatTests/Mocks/MockRealtime.swift
Additional comments not posted (6)
Tests/AblyChatTests/Mocks/MockRealtimeChannel.swift (4)

4-221: LGTM!

The MockRealtimeChannel class provides a way to test the behavior of code that uses the RealtimeChannelProtocol by allowing the test to control the result of attach and detach calls and track the number of times they are called. The unimplemented methods are not required for the current testing needs.


18-43: LGTM!

The Counter class is a useful utility for testing purposes. It is thread-safe and provides methods to increment the counter and check its value. The implementation looks correct and thread-safe.


79-87: LGTM!

The attach method implementation looks correct. It tracks the number of times it is called and invokes the callback with the result set in attachResult. The fatal error if attachResult is not set is a good way to catch misuse of the mock in tests.


97-105: LGTM!

The detach method implementation looks correct. It tracks the number of times it is called and invokes the callback with the result set in detachResult. The fatal error if detachResult is not set is a good way to catch misuse of the mock in tests.

Example/AblyChatExample/Mocks/MockRealtime.swift (2)

16-174: The past comment about un-nesting code is no longer valid in the context of these changes. The introduction of nested classes Channels and Channel provides a logical grouping and encapsulation of related functionalities, justifying the increased indentation.


5-5: Verify the impact of changing the protocol conformance.

Ensure that changing the protocol conformance from ARTRealtimeProtocol to RealtimeClientProtocol does not break any existing code that depends on this mock.

Run the following script to verify the usage of MockRealtime:

Verification successful

Verification successful: No issues found with protocol conformance change.

The change in protocol conformance from ARTRealtimeProtocol to RealtimeClientProtocol in the MockRealtime class does not appear to have caused any issues in the existing codebase. The usage of MockRealtime in test files indicates that it is used for testing purposes, and the tests seem to be structured to accommodate the new protocol conformance. No compilation errors or related issues were found.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the usage of `MockRealtime` after changing the protocol conformance.

# Test: Search for the usage of `MockRealtime`. Expect: No compilation errors related to protocol conformance.
rg --type swift $'MockRealtime' -A 5

Length of output: 11726

Copy link
Collaborator

@maratal maratal left a comment

Choose a reason for hiding this comment

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

LGTM

I didn’t know about this feature in 646c220.
Based on the simplified requirements described in #19. This doesn’t
include the emission of a room status change; will do that in a separate
PR.
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 21da342 and 09e54f6.

Files selected for processing (11)
  • Example/AblyChatExample/Mocks/MockRealtime.swift (2 hunks)
  • Sources/AblyChat/AblyCocoaExtensions/Ably+Concurrency.swift (1 hunks)
  • Sources/AblyChat/AblyCocoaExtensions/Ably+Dependencies.swift (1 hunks)
  • Sources/AblyChat/ChatClient.swift (1 hunks)
  • Sources/AblyChat/Dependencies.swift (1 hunks)
  • Sources/AblyChat/Room.swift (1 hunks)
  • Sources/BuildTool/ProcessRunner.swift (1 hunks)
  • Tests/AblyChatTests/DefaultRoomTests.swift (1 hunks)
  • Tests/AblyChatTests/Mocks/MockChannels.swift (1 hunks)
  • Tests/AblyChatTests/Mocks/MockRealtime.swift (2 hunks)
  • Tests/AblyChatTests/Mocks/MockRealtimeChannel.swift (1 hunks)
Files skipped from review due to trivial changes (2)
  • Sources/AblyChat/AblyCocoaExtensions/Ably+Concurrency.swift
  • Sources/BuildTool/ProcessRunner.swift
Files skipped from review as they are similar to previous changes (7)
  • Sources/AblyChat/AblyCocoaExtensions/Ably+Dependencies.swift
  • Sources/AblyChat/ChatClient.swift
  • Sources/AblyChat/Dependencies.swift
  • Sources/AblyChat/Room.swift
  • Tests/AblyChatTests/DefaultRoomTests.swift
  • Tests/AblyChatTests/Mocks/MockChannels.swift
  • Tests/AblyChatTests/Mocks/MockRealtimeChannel.swift
Additional context used
Learnings (1)
Example/AblyChatExample/Mocks/MockRealtime.swift (4)
Learnt from: lawrence-forooghian
PR: ably-labs/ably-chat-swift#33
File: Sources/AblyChat/Rooms.swift:57-59
Timestamp: 2024-08-29T13:21:27.617Z
Learning: The user, lawrence-forooghian, prefers not to be warned about `fatalError` calls for missing implementations. This preference should be respected in future reviews.
Learnt from: lawrence-forooghian
PR: ably-labs/ably-chat-swift#35
File: Example/AblyChatExample/Mocks/MockRealtime.swift:34-174
Timestamp: 2024-09-02T16:30:41.278Z
Learning: When reviewing code, do not ask lawrence-forooghian about "not yet implemented" `fatalError` calls.
Learnt from: lawrence-forooghian
PR: ably-labs/ably-chat-swift#35
File: Example/AblyChatExample/Mocks/MockRealtime.swift:16-32
Timestamp: 2024-09-02T16:30:26.840Z
Learning: When reviewing code, do not ask lawrence-forooghian about "not yet implemented" `fatalError` calls.
Learnt from: lawrence-forooghian
PR: ably-labs/ably-chat-swift#33
File: Sources/AblyChat/Rooms.swift:9-64
Timestamp: 2024-08-29T10:55:26.337Z
Learning: When reviewing code, do not ask lawrence-forooghian about "not yet implemented" `fatalError` calls.
Additional comments not posted (8)
Tests/AblyChatTests/Mocks/MockRealtime.swift (6)

5-6: LGTM!

The change in protocol conformance from ARTRealtimeProtocol to RealtimeClientProtocol is approved. It aligns with the PR objectives and likely reflects a new approach to handling real-time functionalities.


15-17: LGTM!

The initialization of the channels property in the init(options:) initializer is approved. It ensures that the property is properly initialized when creating instances of MockRealtime.


19-21: LGTM!

The initialization of the channels property in the init(key:) initializer is approved. It ensures that the property is properly initialized when creating instances of MockRealtime.


23-25: LGTM!

The initialization of the channels property in the init(token:) initializer is approved. It ensures that the property is properly initialized when creating instances of MockRealtime.


27-29: LGTM!

The new convenience initializer init(channels:) is approved. It enhances the flexibility of the mock implementation, enabling tests to specify different channel configurations. This improves the usability of the mock class in testing scenarios by providing more control over the mock's state.


38-39: LGTM!

The modification to the create() method to accept a channels parameter is approved. It aligns with the changes made to the initializers and improves the usability of the mock class in testing scenarios by allowing custom channel setups.

Example/AblyChatExample/Mocks/MockRealtime.swift (2)

5-5: LGTM!

The change in protocol conformance from ARTRealtimeProtocol to RealtimeClientProtocol is approved.


14-14: LGTM!

The addition of the channels property is approved.

Copy link
Collaborator

@umair-ably umair-ably left a comment

Choose a reason for hiding this comment

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

LGTM!

@lawrence-forooghian lawrence-forooghian merged commit 8ad7d8d into main Sep 3, 2024
17 checks passed
@lawrence-forooghian lawrence-forooghian deleted the 19-attach-and-detach-room branch September 3, 2024 10:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

3 participants