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

Improve tests #20

Merged
merged 4 commits into from
May 10, 2024
Merged

Improve tests #20

merged 4 commits into from
May 10, 2024

Conversation

Milly
Copy link
Contributor

@Milly Milly commented May 3, 2024

Summary by CodeRabbit

  • New Features
    • Improved error handling in session reservations for increased reliability.
  • Bug Fixes
    • Updated test descriptions and added new test cases for better error management.
  • Refactor
    • Renamed Session to SessionForClient for clarity in client contexts.
  • Tests
    • Enhanced testing frameworks with new stubs and spies for precise client behavior verification.
  • Documentation
    • Adjusted export statements for clearer module interactions.

@Milly Milly requested a review from lambdalisue May 3, 2024 20:48
Copy link

coderabbitai bot commented May 3, 2024

Walkthrough

The recent updates bring improvements to error handling in the Session class and enhance testing practices throughout the codebase. Changes encompass better error management with try-catch in session.ts, refined test descriptions in session_test.ts, a renaming of Session to SessionForClient in client.ts, and enhanced test isolation in client_test.ts. Additionally, the export statements in mod.ts were adjusted for clearer module exports.

Changes

Files Change Summary
session.ts Added error handling in reserve method.
session_test.ts Updated test descriptions, adjusted imports for testing utilities.
client.ts, mod.ts Renamed Session to SessionForClient, adjusted export statements.
client_test.ts Enhanced testing setup with stubs and spies, updated imports for better test control.
.github/workflows/test.yml, deno.jsonc Adjusted commands for testing and coverage workflows in Deno project configuration.
example/client.vim, example/server.ts Modified function calls for improved asynchronous behavior.

🐇✨
O hark! A code so bright and new,
With tests that spy and stubs that glue.
Catch errors swift, let none pass through,
In sessions safe, our bugs we slew.
Hip, hip, hooray, to changes true! 🎉
🐇✨


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.

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 a review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai help to get help.

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

CodeRabbit Configration 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: 3

example/server.ts Show resolved Hide resolved
client.ts Outdated Show resolved Hide resolved
client.ts Outdated Show resolved Hide resolved
client.ts Outdated Show resolved Hide resolved
.github/workflows/test.yml Outdated 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: 1

session.ts Outdated 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: 0

Review Details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits Files that changed from the base of the PR and between 48f877d and 0754a24.
Files selected for processing (3)
  • client.ts (1 hunks)
  • client_test.ts (1 hunks)
  • mod.ts (1 hunks)
Files skipped from review as they are similar to previous changes (1)
  • client.ts
Additional comments not posted (8)
mod.ts (1)

1-1: Change in export statement enhances modularity and control over exported entities.

client_test.ts (7)

17-47: Proper use of testing utilities and assertions in the "Client.reply" test case.


53-76: Consistent and effective testing approach in the "Client.redraw" test case.


82-101: Effective use of mocks and error handling in the "Client.ex" test case.


107-126: Consistent testing methodology applied in the "Client.normal" test case.


132-209: Comprehensive and detailed testing in the "Client.expr" test case, including advanced scenarios with multiple clients.


261-343: Thorough testing of the "Client.call" method, effectively using mocks and handling errors.


349-372: Appropriate testing of the "Client.callNoReply" method, correctly handling cases without responses.

Copy link
Member

@lambdalisue lambdalisue left a comment

Choose a reason for hiding this comment

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

LGTM

@lambdalisue
Copy link
Member

@Milly Could you rebase to tidy commits? The PR includes test improvements and bug fix so I'd like to add merge commit rather than squash merge.

@Milly
Copy link
Contributor Author

Milly commented May 10, 2024

I squashed the commits into units.

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 0754a24 and 023bed6.
Files selected for processing (9)
  • .github/workflows/test.yml (1 hunks)
  • client.ts (1 hunks)
  • client_test.ts (1 hunks)
  • deno.jsonc (1 hunks)
  • example/client.vim (1 hunks)
  • example/server.ts (1 hunks)
  • mod.ts (1 hunks)
  • session.ts (1 hunks)
  • session_test.ts (7 hunks)
Files skipped from review as they are similar to previous changes (8)
  • .github/workflows/test.yml
  • client.ts
  • deno.jsonc
  • example/client.vim
  • example/server.ts
  • mod.ts
  • session.ts
  • session_test.ts
Additional comments not posted (9)
client_test.ts (9)

5-15: Imports are correctly structured and use the latest versions of the libraries.


17-47: The test setup and assertions in the "Client.reply" test case are correctly implemented, ensuring proper behavior verification.


49-76: The "Client.redraw" test case is well-structured with appropriate use of testing utilities and correct assertions.


78-101: The test case for "Client.ex" is correctly implemented, ensuring that both success and error scenarios are properly tested.


103-126: The "Client.normal" test case is well-structured and effectively tests the method's functionality under different scenarios.


128-209: The "Client.expr" test case is comprehensive, effectively testing multiple scenarios and client interactions.


211-255: The "Client.exprNoReply" test case is correctly implemented, ensuring that the method's behavior is thoroughly tested.


257-343: The "Client.call" test case is comprehensive and well-structured, effectively testing the method under various scenarios.


345-372: The "Client.callNoReply" test case is correctly implemented, ensuring that the method's behavior is thoroughly tested.

@lambdalisue lambdalisue merged commit 8cd38d5 into vim-denops:main May 10, 2024
2 checks passed
@Milly Milly deleted the improve-tests branch May 10, 2024 11:37
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