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

🌿 split server.vim tests #405

Merged
merged 1 commit into from
Aug 7, 2024
Merged

🌿 split server.vim tests #405

merged 1 commit into from
Aug 7, 2024

Conversation

Milly
Copy link
Contributor

@Milly Milly commented Aug 7, 2024

  • Tests can now be run separately.
  • Improved parallelism in CI.

Test codes are not changed.

Summary by CodeRabbit

  • New Features

    • Introduced comprehensive test suites for server functions: connect(), start(), close(), stop(), and status(), enhancing reliability and error handling in the Denops framework.
  • Bug Fixes

    • Improved testing scenarios to handle various server states, ensuring accurate status reporting and event firing during connection and disconnection processes.
  • Documentation

    • Enhanced test coverage documentation for the Denops server functionalities, providing clarity on test cases and expected behaviors.

- Tests can now be run separately.
- Improved parallelism in CI.
Copy link

coderabbitai bot commented Aug 7, 2024

Walkthrough

The recent changes introduce a suite of comprehensive tests for the Denops server functionalities, including connection, starting, stopping, and status checking. Each test file employs asynchronous patterns to ensure robust validation across various scenarios, enhancing reliability and error handling within the Denops framework.

Changes

Files Change Summary
tests/denops/runtime/functions/server/*.ts New test files added for close(), connect(), start(), status(), and stop() functions, each covering multiple scenarios to validate server behavior and states.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant Denops
    participant Server

    User->>Denops: call denops#server#start()
    Denops->>Server: Check if server is disabled
    alt Server Disabled
        Server-->>Denops: Return falsy (status: stopped)
    else Server Enabled
        Denops->>Server: Start server
        Server-->>Denops: Status: starting
        Server-->>Denops: Status: running (DenopsReady event)
    end
Loading

🐰 In the land of Denops, where servers play,
A suite of tests has come to stay.
With close and start, each state defined,
Errors and bugs, we’ll surely unwind.
Hop along, let’s ensure it’s right,
For a smoother ride, we’ll test day and night! 🌟


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 as 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.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

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.

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 df8b125 and 8bf5663.

Files selected for processing (5)
  • tests/denops/runtime/functions/server/close_test.ts (1 hunks)
  • tests/denops/runtime/functions/server/connect_test.ts (1 hunks)
  • tests/denops/runtime/functions/server/start_test.ts (1 hunks)
  • tests/denops/runtime/functions/server/status_test.ts (1 hunks)
  • tests/denops/runtime/functions/server/stop_test.ts (1 hunks)
Additional comments not posted (34)
tests/denops/runtime/functions/server/status_test.ts (7)

15-21: LGTM!

The test step correctly verifies that the status is 'stopped' when no server is running.


35-44: LGTM!

The test step correctly verifies that the status is 'starting' when denops#server#start() is called.


46-60: LGTM!

The test step correctly verifies that the status is 'preparing' before DenopsReady is fired.


62-69: LGTM!

The test step correctly verifies that the status is 'running' after DenopsReady is fired.


71-84: LGTM!

The test step correctly verifies that the status is 'closing' when denops#server#close() is called.


86-93: LGTM!

The test step correctly verifies that the status is 'closed' after DenopsClosed is fired.


95-103: LGTM!

The test step correctly verifies that the status is 'stopped' after denops#server#stop() is called.

tests/denops/runtime/functions/server/stop_test.ts (6)

27-40: LGTM!

The test step correctly verifies that the status does not change from 'stopped' if the server is not yet started.


62-69: LGTM!

The test step correctly verifies that the status changes to 'closing' immediately when denops#server#stop() is called.


70-73: LGTM!

The test step correctly verifies that the DenopsClosed event is fired.


74-79: LGTM!

The test step correctly verifies that the DenopsProcessStopped event is fired.


81-85: LGTM!

The test step correctly verifies that the status changes to 'stopped' asynchronously.


112-119: LGTM!

The test step correctly verifies that the status does not change from 'running' when connected to a shared server.

tests/denops/runtime/functions/server/close_test.ts (6)

34-47: LGTM!

The test step correctly verifies that the status does not change from 'stopped' if the server is not yet connected.


49-60: LGTM!

The test step correctly verifies that the DenopsClosed event is not fired if the server is not yet connected.


81-87: LGTM!

The test step correctly verifies that the status changes to 'closing' immediately when denops#server#close() is called.


89-92: LGTM!

The test step correctly verifies that the DenopsClosed event is fired.


93-96: LGTM!

The test step correctly verifies that the status changes to 'closed' asynchronously.


98-108: LGTM!

The test step correctly verifies that the local server is not stopped when denops#server#close() is called.

tests/denops/runtime/functions/server/connect_test.ts (7)

36-63: LGTM! Well-structured test scenario for "if denops disabled".

The test scenario thoroughly checks the behavior when denops is disabled, covering return values, status, and event firing.


65-216: LGTM! Comprehensive test scenario for "if not yet connected".

The test scenario thoroughly checks the behavior when the server is not yet connected, covering empty address, invalid address, and valid address sub-scenarios.


219-272: LGTM! Well-structured test scenario for "if already connected to local-server".

The test scenario thoroughly checks the behavior when already connected to a local server, covering return values, status, and event firing.


274-323: LGTM! Well-structured test scenario for "if already connected to shared-server".

The test scenario thoroughly checks the behavior when already connected to a shared server, covering return values, status, and event firing.


325-385: LGTM! Well-structured test scenario for "if the channel is closed unexpectedly".

The test scenario thoroughly checks the behavior when the channel is closed unexpectedly, covering event firing, status change, and reconnection.


387-433: LGTM! Well-structured test scenario for "if reconnect count exceed".

The test scenario thoroughly checks the behavior when the reconnect count exceeds the threshold, covering status change and warning message.


Line range hint 393-439:
LGTM! Well-structured test scenario for "if the server is stopped with a constraint error (issue 401)".

The test scenario thoroughly checks the behavior when the server is stopped with a constraint error, covering event firing, status change, and warning message.

tests/denops/runtime/functions/server/start_test.ts (8)

49-76: LGTM! Well-structured test scenario for "if denops disabled".

The test scenario thoroughly checks the behavior when denops is disabled, covering return values, status, and event firing.


78-120: LGTM! Well-structured test scenario for "if not yet started".

The test scenario thoroughly checks the behavior when the server is not yet started, covering return values, status, and event firing.


122-167: LGTM! Well-structured test scenario for "if already starting".

The test scenario thoroughly checks the behavior when the server is already starting, covering return values, status, and event firing.


169-214: LGTM! Well-structured test scenario for "if already connected to shared-server".

The test scenario thoroughly checks the behavior when already connected to a shared server, covering return values, status, and warning message.


216-273: LGTM! Well-structured test scenario for "if deno command is not exists".

The test scenario thoroughly checks the behavior when the deno command is not found, covering return values, status, event firing, and warning message.


275-340: LGTM! Well-structured test scenario for "if the server is stopped unexpectedly".

The test scenario thoroughly checks the behavior when the server is stopped unexpectedly, covering event firing, status change, and restarting.


342-390: LGTM! Well-structured test scenario for "if restart count exceed".

The test scenario thoroughly checks the behavior when the restart count exceeds the threshold, covering status change and warning message.


393-439: LGTM! Well-structured test scenario for "if the server is stopped with a constraint error (issue 401)".

The test scenario thoroughly checks the behavior when the server is stopped with a constraint error, covering event firing, status change, and warning message.

Copy link

codecov bot commented Aug 7, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 95.52%. Comparing base (df8b125) to head (8bf5663).

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #405   +/-   ##
=======================================
  Coverage   95.52%   95.52%           
=======================================
  Files          23       23           
  Lines        1384     1384           
  Branches      174      174           
=======================================
  Hits         1322     1322           
  Misses         59       59           
  Partials        3        3           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@Milly
Copy link
Contributor Author

Milly commented Aug 7, 2024

Local testing was sped up, unfortunately Github Action didn't show any improvement due to parallelism issues. (I checked runs n=1)

@Milly Milly requested a review from lambdalisue August 7, 2024 11:20
@Milly
Copy link
Contributor Author

Milly commented Aug 7, 2024

functions/plugin tests can also be split, but I have put it off because I discovered a bug in them.

@lambdalisue
Copy link
Member

Thanks 🎉

@lambdalisue lambdalisue merged commit 95f076b into main Aug 7, 2024
9 checks passed
@lambdalisue lambdalisue deleted the split-tests branch August 7, 2024 15:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants