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

🌿 add module that resolves testdata path or URL #417

Merged
merged 1 commit into from
Sep 14, 2024

Conversation

Milly
Copy link
Contributor

@Milly Milly commented Sep 13, 2024

Changes only for tests.

Summary by CodeRabbit

  • New Features

    • Introduced a new import mapping for /denops-testdata/ to enhance test data organization.
    • Added functions for resolving test data paths and URLs, improving access to test resources.
  • Bug Fixes

    • Replaced local resolve functions with centralized utility functions for better maintainability across various test files.
  • Refactor

    • Removed redundant resolve functions from multiple test files, streamlining the codebase and enhancing clarity.

Copy link

coderabbitai bot commented Sep 13, 2024

Walkthrough

The changes involve the introduction of a new import mapping in the deno.jsonc configuration file, which points to a dedicated directory for test data. Additionally, several test files have been updated to replace local path resolution functions with centralized utility functions for resolving test data paths and URLs. This includes the removal of redundant code across multiple test files, enhancing the organization and clarity of the test setup.

Changes

File(s) Change Summary
deno.jsonc Added import mapping for /denops-testdata/ pointing to ./tests/denops/testdata/.
denops/@denops-private/service_test.ts Replaced local resolve function with resolveTestDataURL for URL resolution of test scripts, removing the local function entirely.
tests/denops/runtime/functions/plugin/*.ts (check_type_test.ts, discover_test.ts, is_loaded_test.ts, load_test.ts, reload_test.ts, unload_test.ts, wait_async_test.ts, wait_test.ts) Removed local resolve function and replaced it with resolveTestDataPath for path resolution in various test files, enhancing consistency and maintainability.
tests/denops/runtime/functions/server/start_test.ts Replaced local resolve function with resolveTestDataURL for URL resolution, streamlining the code.
tests/denops/testdata/resolve.ts Introduced new file with resolveTestDataPath and resolveTestDataURL functions for centralized path and URL resolution.
tests/denops/testutil/shared_server_test.ts Updated to use resolveTestDataPath instead of local resolve function for path resolution in test cases, removing the local function entirely.

Sequence Diagram(s)

sequenceDiagram
    participant Test as Test Files
    participant Resolver as Resolver Module
    participant Data as Test Data

    Test->>Resolver: Call resolveTestDataPath()
    Resolver->>Data: Access test data script
    Data-->>Resolver: Return path to test data
    Resolver-->>Test: Return resolved path
Loading

🐰 In the land of code so bright,
A mapping added, what a sight!
With paths resolved and functions neat,
The tests now dance on happy feet.
No more confusion, all is clear,
Hooray for changes, let’s all cheer! 🎉

Tip

OpenAI O1 model for chat
  • We have deployed OpenAI's latest O1 model for chat.
  • OpenAI claims that this model has superior reasoning capabilities than their GPT-4o model.
  • Please share any feedback with us in the discussions post.

Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between f32f028 and ee31acf.

Files selected for processing (13)
  • deno.jsonc (1 hunks)
  • denops/@denops-private/service_test.ts (1 hunks)
  • tests/denops/runtime/functions/plugin/check_type_test.ts (1 hunks)
  • tests/denops/runtime/functions/plugin/discover_test.ts (1 hunks)
  • tests/denops/runtime/functions/plugin/is_loaded_test.ts (1 hunks)
  • tests/denops/runtime/functions/plugin/load_test.ts (1 hunks)
  • tests/denops/runtime/functions/plugin/reload_test.ts (1 hunks)
  • tests/denops/runtime/functions/plugin/unload_test.ts (1 hunks)
  • tests/denops/runtime/functions/plugin/wait_async_test.ts (1 hunks)
  • tests/denops/runtime/functions/plugin/wait_test.ts (1 hunks)
  • tests/denops/runtime/functions/server/start_test.ts (2 hunks)
  • tests/denops/testdata/resolve.ts (1 hunks)
  • tests/denops/testutil/shared_server_test.ts (3 hunks)
Files skipped from review due to trivial changes (1)
  • tests/denops/runtime/functions/plugin/wait_async_test.ts
Additional comments not posted (31)
tests/denops/testdata/resolve.ts (2)

4-6: LGTM!

The resolveTestDataPath function is implemented correctly and uses the join method from the @std/path module to handle path concatenation in a cross-platform manner. The function has clear documentation explaining its purpose.


9-11: LGTM!

The resolveTestDataURL function is implemented correctly and uses the URL constructor with the current module's URL to generate an absolute URL from the provided relative path. The function has clear documentation explaining its purpose.

deno.jsonc (1)

20-20: LGTM!

Adding a dedicated import mapping for test data is a good practice to improve the organization of test-related resources. The mapping is correctly defined, pointing to the appropriate directory.

tests/denops/runtime/functions/plugin/discover_test.ts (2)

7-7: LGTM!

Importing resolveTestDataPath from a dedicated test data module is a good practice for organizing test-related code. This change centralizes the path resolution logic, which enhances code clarity and maintainability.


13-13: LGTM!

Using the imported resolveTestDataPath function to resolve the path to the dummy_plugins directory simplifies the code and removes the need for a local path resolution function. This change is consistent with the import statement added at line 7.

tests/denops/testutil/shared_server_test.ts (3)

9-9: LGTM!

The import statement for resolveTestDataPath aligns with the PR objective of introducing a module to resolve test data paths. This change enhances the organization and maintainability of the test code.


52-52: LGTM!

Replacing the local resolve function with the centralized resolveTestDataPath function enhances the clarity and maintainability of the code by standardizing the way test data paths are resolved. This change aligns with the PR objective of introducing a module to resolve test data paths.


97-97: LGTM!

Replacing the local resolve function with the centralized resolveTestDataPath function enhances the clarity and maintainability of the code by standardizing the way test data paths are resolved. This change aligns with the PR objective of introducing a module to resolve test data paths.

tests/denops/runtime/functions/plugin/check_type_test.ts (2)

6-6: LGTM!

The import of resolveTestDataPath from /denops-testdata/resolve.ts aligns with the PR objective of introducing a module to resolve test data paths or URLs. This change enhances code organization and reusability by leveraging a dedicated utility function.


10-10: Excellent refactor!

Replacing the custom resolve function with the resolveTestDataPath utility simplifies the code and enhances maintainability. This change leverages the new module for resolving test data paths, eliminating redundant logic and improving code clarity.

tests/denops/runtime/functions/plugin/is_loaded_test.ts (3)

3-3: LGTM!

The import statement for the resolveTestDataPath function from the denops-testdata module is correct and follows the proper syntax. Using a dedicated module for resolving test data paths is a good practice for maintaining consistency and reusability across tests.


9-13: LGTM!

The changes are consistent with the removal of the resolve function and the adoption of the resolveTestDataPath function from the denops-testdata module. The test data file paths are correctly passed as arguments to the resolveTestDataPath function, maintaining the integrity of the test setup.


Line range hint 15-270: LGTM!

The test cases for the denops#plugin#is_loaded() function are comprehensive and cover various scenarios. They use the assertEquals and assertRejects functions from the jsr:@std/assert module for making assertions. The test cases are well-structured and follow a consistent pattern of setup, execution, and assertion, making them easy to understand and maintain.

tests/denops/runtime/functions/plugin/unload_test.ts (3)

7-7: LGTM!

The import statement is syntactically correct and promotes code reuse by using a centralized utility function for resolving test data paths.


13-16: LGTM!

The changes to use the imported resolveTestDataPath function for resolving test data script paths are syntactically correct and promote consistency in path resolution across the codebase.


Line range hint 1-1: LGTM!

The removal of the local resolve function is consistent with the changes to use the imported resolveTestDataPath function for path resolution. This change reduces code duplication and improves maintainability.

tests/denops/runtime/functions/plugin/reload_test.ts (2)

7-7: LGTM!

The import statement for the resolveTestDataPath function is valid and follows the correct syntax.


13-16: LGTM!

The resolveTestDataPath function is used correctly to resolve the test data paths for the dummy_valid_plugin.ts and dummy_invalid_dispose_plugin.ts scripts.

tests/denops/runtime/functions/plugin/load_test.ts (4)

7-7: LGTM!

The import statement is valid and follows the correct syntax. Importing the resolveTestDataPath function from a centralized module aligns with the PR objective of introducing a new module to resolve test data paths.


13-13: LGTM!

Replacing the local resolve function with the centralized resolveTestDataPath function improves maintainability and consistency across the test suite. This change aligns with the PR objective of updating test files to use centralized utility functions for resolving test data paths.


14-14: LGTM!

Replacing the local resolve function with the centralized resolveTestDataPath function is consistent with the previous change and aligns with the PR objective. This improves maintainability and clarity of the test setup.


15-15: LGTM!

This change is consistent with the previous modifications and aligns with the PR objective. Replacing the local resolve function with the centralized resolveTestDataPath function improves maintainability and clarity of the test setup.

tests/denops/runtime/functions/plugin/wait_test.ts (4)

10-10: LGTM!

Importing the resolveTestDataPath function from the denops-testdata module is a good practice for maintainability and consistency.


16-16: LGTM!

Replacing the local resolve function call with the resolveTestDataPath function is consistent with the new approach and maintains the functionality of the test case.


17-17: LGTM!

Replacing the local resolve function call with the resolveTestDataPath function is consistent with the new approach and maintains the functionality of the test case.


18-19: LGTM!

Replacing the local resolve function calls with the resolveTestDataPath function is consistent with the new approach and maintains the functionality of the test cases.

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

11-11: LGTM!

The change enhances the clarity and maintainability of the code by leveraging a dedicated utility for URL resolution. The local resolve function has been removed entirely, streamlining the code and potentially reducing redundancy.


408-408: LGTM!

The change is consistent with the introduction of the new import statement for the function resolveTestDataURL from the module /denops-testdata/resolve.ts. The change enhances the clarity and maintainability of the code by leveraging a dedicated utility for URL resolution.

denops/@denops-private/service_test.ts (3)

20-20: LGTM!

The import statement for the toFileUrl function is correct and follows the JSR module resolution syntax.


24-24: LGTM!

The import statement for the resolveTestDataURL function is correct and follows the module resolution syntax.


30-41: Standardizing test data URL resolution. LGTM!

The changes replace the local resolve function calls with the centralized resolveTestDataURL function for resolving test data URLs. This standardizes the way test data URLs are resolved and improves maintainability by removing redundant code.


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.

Copy link

codecov bot commented Sep 13, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 95.90%. Comparing base (f32f028) to head (ee31acf).
Report is 2 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #417      +/-   ##
==========================================
+ Coverage   95.44%   95.90%   +0.46%     
==========================================
  Files          23       24       +1     
  Lines        1384     1393       +9     
  Branches      174      174              
==========================================
+ Hits         1321     1336      +15     
+ Misses         60       55       -5     
+ Partials        3        2       -1     

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

@lambdalisue lambdalisue merged commit aed70a1 into main Sep 14, 2024
9 checks passed
@lambdalisue lambdalisue deleted the resolves-testdata branch September 14, 2024 03:10
@coderabbitai coderabbitai bot mentioned this pull request Nov 8, 2024
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