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

fix: dojo-lang tests with default namespace #2422

Merged

Conversation

remybar
Copy link
Contributor

@remybar remybar commented Sep 13, 2024

Description

Now that namespace configuration has been moved from Scarb.toml to dojo_<PROFILE>.toml, dojo-lang code expansion tests have no more default namespace in their configuration leading to several errors like error: The namespace '' can only contain characters (a-z/A-Z), digits (0-9) and underscore (_). for nominal cases.

This PR adds a default namespace dojo_test if the test configuration is empty.

Tests

  • Yes
  • No, because they aren't needed
  • No, because I need help

Added to documentation?

  • README.md
  • Dojo Book
  • No documentation needed

Checklist

  • I've formatted my code (scripts/prettier.sh, scripts/rust_fmt.sh, scripts/cairo_fmt.sh)
  • I've linted my code (scripts/clippy.sh, scripts/docs.sh)
  • I've commented my code
  • I've requested a review after addressing the comments

Summary by CodeRabbit

  • New Features

    • Introduced a fallback mechanism for configuration handling in tests, ensuring a default namespace is always available.
  • Bug Fixes

    • Improved robustness of the testing framework by preventing errors from missing configurations.
  • Documentation

    • Updated import statements to reflect new configuration usage.

Copy link

coderabbitai bot commented Sep 13, 2024

Walkthrough

Ohayo, sensei! The changes in this pull request enhance the configuration handling in the test_expand_plugin_inner function. A fallback mechanism has been introduced to ensure that a default namespace configuration is available when no configuration is provided. This prevents errors related to missing configurations. Additionally, the import statements have been updated to include Cfg alongside CfgSet, while maintaining the overall structure of the function.

Changes

Files Change Summary
crates/dojo-lang/src/plugin_test.rs Enhanced configuration handling in test_expand_plugin_inner by adding a fallback mechanism for default configurations and updated import statements to include Cfg.

Sequence Diagram(s)

sequenceDiagram
    participant Test as Test Framework
    participant Inputs as Inputs Map
    participant Config as Configuration

    Test->>Inputs: Request configuration (cfg_set)
    alt Configuration exists
        Inputs-->>Test: Return cfg_set
    else Configuration missing
        Test->>Config: Create default CfgSet
        Config-->>Test: Return default cfg_set
    end
Loading

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.yaml
Review profile: CHILL

Commits

Files that changed from the base of the PR and between ebb3b70 and 13a30b5.

Files selected for processing (1)
  • crates/dojo-lang/src/plugin_test.rs (3 hunks)
Additional comments not posted (4)
crates/dojo-lang/src/plugin_test.rs (4)

7-7: Ohayo sensei! LGTM!

The import statement update looks good. Adding Cfg alongside CfgSet is necessary for the new usage in the code.


21-22: Ohayo sensei! LGTM!

The new imports are necessary for the fallback mechanism that ensures a default namespace configuration. Good job!


95-105: Ohayo sensei! LGTM!

The fallback mechanism for handling missing configurations looks great! It ensures that tests have a valid configuration even when no configuration is provided. This change improves the robustness of the testing framework. Well done!


106-106: Ohayo sensei! LGTM!

Setting the cfg_set in the database is the correct way to update the configuration. This change aligns with the updated configuration handling logic. Good job!


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.

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 68.07%. Comparing base (ebb3b70) to head (13a30b5).
Report is 10 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2422      +/-   ##
==========================================
+ Coverage   67.89%   68.07%   +0.17%     
==========================================
  Files         364      364              
  Lines       47773    47774       +1     
==========================================
+ Hits        32435    32521      +86     
+ Misses      15338    15253      -85     

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

Copy link
Collaborator

@glihm glihm left a comment

Choose a reason for hiding this comment

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

Good catch thanks @remybar.

@glihm glihm merged commit 435c2d1 into dojoengine:main Sep 16, 2024
15 checks passed
@kariy kariy mentioned this pull request Sep 19, 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