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

test: fix failing runtime/v2 test #22760

Merged
merged 1 commit into from
Dec 5, 2024
Merged

test: fix failing runtime/v2 test #22760

merged 1 commit into from
Dec 5, 2024

Conversation

aljo242
Copy link
Contributor

@aljo242 aljo242 commented Dec 4, 2024

Fixes a test that must have been failing once the stfRouterWrapper type was added to wrap RouterBuilders.

The incorrect type was being expected in the Mock statement

Summary by CodeRabbit

  • Tests
    • Updated the mock expectations in the service registration tests to enhance validation of interactions.

@aljo242 aljo242 requested review from julienrbrt, hieuvubk and a team as code owners December 4, 2024 21:20
Copy link
Contributor

coderabbitai bot commented Dec 4, 2024

📝 Walkthrough

Walkthrough

The changes in this pull request modify the TestRegisterServices function within the runtime/v2/services_test.go file. The main adjustment involves the introduction of newStfRouterWrapper to wrap the app.msgRouterBuilder and app.queryRouterBuilder. This change alters how mock expectations are set for the MockModule instance by using pointers to msgWrapper and queryWrapper, affecting the argument types passed to the mock methods.

Changes

File Change Summary
runtime/v2/services_test.go Modified TestRegisterServices to use newStfRouterWrapper, changing how mock expectations are set for MockModule.

Possibly related PRs

  • test(server/v2/stf): Add test for mergeiterator #22141: The changes in this PR involve adding a new test for the MergedIterator functionality, which may relate to the testing practices and mock expectations similar to those modified in the TestRegisterServices function in the main PR.
  • test(systemtests): fix failing tests #22145: This PR focuses on fixing failing tests within the system tests, which may involve similar testing methodologies and mock setups as seen in the changes made to the TestRegisterServices function in the main PR.

Suggested labels

C:server/v2, C:server/v2 stf

Suggested reviewers

  • kocubinski
  • testinginprod
  • julienrbrt

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>, please review it.
    • 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 gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @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
Contributor

@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 and nitpick comments (1)
runtime/v2/services_test.go (1)

42-46: Consider adding edge cases to strengthen test coverage

While the current test effectively verifies the basic service registration flow, consider adding test cases for:

  1. Multiple module registrations
  2. Error scenarios when registration fails
  3. Validation of the actual routing behavior through the wrapper

This would provide more comprehensive coverage of the stfRouterWrapper integration.

Would you like me to help generate additional test cases to improve coverage?

📜 Review details

Configuration used: .coderabbit.yml
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 556102c and 43e7131.

📒 Files selected for processing (1)
  • runtime/v2/services_test.go (1 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
runtime/v2/services_test.go (2)

Pattern **/*.go: Review the Golang code for conformity with the Uber Golang style guide, highlighting any deviations.


Pattern **/*_test.go: "Assess the unit test code assessing sufficient code coverage for the changes associated in the pull request"

🔇 Additional comments (2)
runtime/v2/services_test.go (2)

45-46: LGTM! Mock expectations are properly configured

The mock expectations are correctly set up with:

  • Proper pointer receivers for the wrapped routers
  • Single call verification using .Once()
  • Consistent pattern for both message and query handlers

This change aligns well with the PR objective of fixing the failing test due to the stfRouterWrapper integration.


42-43: Verify the implementation of newStfRouterWrapper

The test uses newStfRouterWrapper which is crucial for the fix, but we should verify its implementation to ensure it properly wraps the router builders.

✅ Verification successful

newStfRouterWrapper implementation is correct and consistent

The implementation in runtime/v2/manager.go shows that newStfRouterWrapper properly initializes a wrapper structure with:

  • A router builder field (stfRouter)
  • An error field initialized to nil
  • A handlers map initialized as empty

The usage in the test file is consistent with this implementation, wrapping both message and query router builders in the same way. The wrapper provides a clean abstraction for handling routing functionality while maintaining error state and handler mappings.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for the implementation of newStfRouterWrapper
ast-grep --pattern 'func newStfRouterWrapper($$$) $$$'

# Search for any related tests of the wrapper
rg -g '**/*_test.go' 'newStfRouterWrapper'

Length of output: 663


Script:

#!/bin/bash
# Let's check the stfRouterWrapper type definition and its usage
ast-grep --pattern 'type stfRouterWrapper struct {$$$}'

# Let's also check how queryRouterBuilder is used with this wrapper
rg "queryRouterBuilder.*stfRouterWrapper" -A 3 -B 3

Length of output: 415

Copy link
Member

@julienrbrt julienrbrt left a comment

Choose a reason for hiding this comment

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

Thanks!!

@julienrbrt julienrbrt added this pull request to the merge queue Dec 5, 2024
Merged via the queue into cosmos:main with commit 227854e Dec 5, 2024
73 of 81 checks passed
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.

3 participants