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

Get cognitarium address on new dataverse client #18

Merged
merged 8 commits into from
Aug 27, 2024

Conversation

bdeneux
Copy link
Contributor

@bdeneux bdeneux commented Aug 23, 2024

First PR that initiate the dataverse client by requesting cognitarium address on dataverse contract and return a new Client. Including mock of dataverse client generated by axone-contract-schema.

Copy link
Contributor

coderabbitai bot commented Aug 23, 2024

Walkthrough

The changes involve the introduction of mock generation commands in the Makefile, modifications to the Client interface and its implementation in the dataverse package, the addition of unit tests for client creation, and updates to proxy methods. New mock files for QueryClient interfaces from dataverse-schema and cognitarium-schema are also created to enhance testing capabilities. Method names are standardized to reflect their functionality better.

Changes

Files Change Summary
Makefile, testutil/dataverse_client_mocks.go, testutil/cognitarium_client_mocks.go Added mock generation commands for QueryClient interfaces, creating MockDataverseQueryClient and MockCognitariumQueryClient.
dataverse/client.go, dataverse/client_test.go Renamed GetGovAddr to GetResourceGovAddr, introduced NewClient for instantiation, and added unit tests for NewDataverseClient.
provider/storage/proxy.go Updated NewProxy and Read methods to use GetResourceGovAddr instead of GetGovAddr.
testutil/dataverse_mocks.go Renamed GetGovAddr to GetResourceGovAddr in mock implementations to align with the updated interface.

Sequence Diagram(s)

sequenceDiagram
    participant Client
    participant DataverseClient
    participant Proxy
    participant MockClient

    Client->>DataverseClient: NewDataverseClient()
    activate DataverseClient
    DataverseClient-->>Client: Return Client instance
    deactivate DataverseClient

    Client->>Proxy: Read()
    activate Proxy
    Proxy->>DataverseClient: GetResourceGovAddr()
    activate DataverseClient
    DataverseClient-->>Proxy: Return resource address
    deactivate DataverseClient
    Proxy-->>Client: Return data
    deactivate Proxy
Loading

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

codecov bot commented Aug 26, 2024

Codecov Report

Attention: Patch coverage is 13.20755% with 92 lines in your changes missing coverage. Please review.

Files Patch % Lines
testutil/cognitarium_client_mocks.go 0.00% 58 Missing ⚠️
testutil/dataverse_client_mocks.go 0.00% 19 Missing ⚠️
dataverse/client.go 60.86% 9 Missing ⚠️
testutil/dataverse_mocks.go 0.00% 4 Missing ⚠️
provider/storage/proxy.go 0.00% 2 Missing ⚠️
Files Coverage Δ
provider/storage/proxy.go 0.00% <0.00%> (ø)
testutil/dataverse_mocks.go 0.00% <0.00%> (ø)
dataverse/client.go 60.86% <60.86%> (ø)
testutil/dataverse_client_mocks.go 0.00% <0.00%> (ø)
testutil/cognitarium_client_mocks.go 0.00% <0.00%> (ø)

... and 5 files with indirect coverage changes

@bdeneux bdeneux changed the title Get governance address from dataverse Get cognitarium address on new dataverse client Aug 26, 2024
@bdeneux bdeneux marked this pull request as ready for review August 26, 2024 13:03
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: 4

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 7a1aad8 and 9b2e1e3.

Files ignored due to path filters (2)
  • go.mod is excluded by !**/*.mod
  • go.sum is excluded by !**/*.sum, !**/*.sum
Files selected for processing (7)
  • Makefile (1 hunks)
  • dataverse/client.go (1 hunks)
  • dataverse/client_test.go (1 hunks)
  • provider/storage/proxy.go (2 hunks)
  • testutil/cognitarium_client_mocks.go (1 hunks)
  • testutil/dataverse_client_mocks.go (1 hunks)
  • testutil/dataverse_mocks.go (1 hunks)
Additional context used
GitHub Check: codecov/patch
dataverse/client.go

[warning] 36-39: dataverse/client.go#L36-L39
Added lines #L36 - L39 were not covered by tests


[warning] 42-42: dataverse/client.go#L42
Added line #L42 was not covered by tests


[warning] 45-46: dataverse/client.go#L45-L46
Added lines #L45 - L46 were not covered by tests


[warning] 49-50: dataverse/client.go#L49-L50
Added lines #L49 - L50 were not covered by tests

testutil/dataverse_mocks.go

[warning] 58-58: testutil/dataverse_mocks.go#L58
Added line #L58 was not covered by tests


[warning] 60-60: testutil/dataverse_mocks.go#L60
Added line #L60 was not covered by tests


[warning] 67-67: testutil/dataverse_mocks.go#L67
Added line #L67 was not covered by tests


[warning] 69-69: testutil/dataverse_mocks.go#L69
Added line #L69 was not covered by tests

provider/storage/proxy.go

[warning] 41-41: provider/storage/proxy.go#L41
Added line #L41 was not covered by tests


[warning] 66-66: provider/storage/proxy.go#L66
Added line #L66 was not covered by tests

testutil/dataverse_client_mocks.go

[warning] 33-36: testutil/dataverse_client_mocks.go#L33-L36
Added lines #L33 - L36 were not covered by tests


[warning] 40-41: testutil/dataverse_client_mocks.go#L40-L41
Added lines #L40 - L41 were not covered by tests


[warning] 45-49: testutil/dataverse_client_mocks.go#L45-L49
Added lines #L45 - L49 were not covered by tests


[warning] 51-54: testutil/dataverse_client_mocks.go#L51-L54
Added lines #L51 - L54 were not covered by tests


[warning] 58-61: testutil/dataverse_client_mocks.go#L58-L61
Added lines #L58 - L61 were not covered by tests

testutil/cognitarium_client_mocks.go

[warning] 33-36: testutil/cognitarium_client_mocks.go#L33-L36
Added lines #L33 - L36 were not covered by tests


[warning] 40-41: testutil/cognitarium_client_mocks.go#L40-L41
Added lines #L40 - L41 were not covered by tests


[warning] 45-49: testutil/cognitarium_client_mocks.go#L45-L49
Added lines #L45 - L49 were not covered by tests


[warning] 51-54: testutil/cognitarium_client_mocks.go#L51-L54
Added lines #L51 - L54 were not covered by tests


[warning] 58-61: testutil/cognitarium_client_mocks.go#L58-L61
Added lines #L58 - L61 were not covered by tests


[warning] 65-69: testutil/cognitarium_client_mocks.go#L65-L69
Added lines #L65 - L69 were not covered by tests


[warning] 71-74: testutil/cognitarium_client_mocks.go#L71-L74
Added lines #L71 - L74 were not covered by tests


[warning] 78-81: testutil/cognitarium_client_mocks.go#L78-L81
Added lines #L78 - L81 were not covered by tests


[warning] 85-89: testutil/cognitarium_client_mocks.go#L85-L89
Added lines #L85 - L89 were not covered by tests


[warning] 91-94: testutil/cognitarium_client_mocks.go#L91-L94
Added lines #L91 - L94 were not covered by tests


[warning] 98-101: testutil/cognitarium_client_mocks.go#L98-L101
Added lines #L98 - L101 were not covered by tests


[warning] 105-109: testutil/cognitarium_client_mocks.go#L105-L109
Added lines #L105 - L109 were not covered by tests


[warning] 111-114: testutil/cognitarium_client_mocks.go#L111-L114
Added lines #L111 - L114 were not covered by tests


[warning] 118-121: testutil/cognitarium_client_mocks.go#L118-L121
Added lines #L118 - L121 were not covered by tests

Additional comments not posted (21)
dataverse/client.go (5)

3-9: LGTM!

The import statements are correct and necessary for the functionality.

The code changes are approved.


12-14: LGTM!

The renaming of the method GetGovAddr to GetResourceGovAddr improves clarity and aligns with the new resource management context.

The code changes are approved.


16-19: LGTM!

The client struct is correctly defined to hold necessary client information.

The code changes are approved.


21-31: LGTM!

The NewDataverseClient function is correctly implemented and handles errors appropriately.

The code changes are approved.


53-61: LGTM!

The getCognitariumAddr function is correctly implemented and handles errors appropriately.

The code changes are approved.

dataverse/client_test.go (3)

3-13: LGTM!

The import statements are correct and necessary for the functionality.

The code changes are approved.


15-34: LGTM!

The test cases for NewDataverseClient are well-defined and cover the necessary scenarios.

The code changes are approved.


36-68: LGTM!

The test implementation for NewDataverseClient is correct and verifies the necessary scenarios.

The code changes are approved.

provider/storage/proxy.go (2)

41-41: LGTM! But add a test for the new line.

The change improves the specificity of the governance address retrieval process. However, the new line is not covered by tests.

Consider adding a test to cover this line.

Tools
GitHub Check: codecov/patch

[warning] 41-41: provider/storage/proxy.go#L41
Added line #L41 was not covered by tests


66-66: LGTM! But add a test for the new line.

The change improves the specificity of the governance address retrieval process. However, the new line is not covered by tests.

Consider adding a test to cover this line.

Tools
GitHub Check: codecov/patch

[warning] 66-66: provider/storage/proxy.go#L66
Added line #L66 was not covered by tests

testutil/dataverse_client_mocks.go (4)

33-36: LGTM! But add a test for the function.

The function is correctly implemented, but it is not covered by tests.

Consider adding a test to cover this function.

Tools
GitHub Check: codecov/patch

[warning] 33-36: testutil/dataverse_client_mocks.go#L33-L36
Added lines #L33 - L36 were not covered by tests


40-41: LGTM! But add a test for the function.

The function is correctly implemented, but it is not covered by tests.

Consider adding a test to cover this function.

Tools
GitHub Check: codecov/patch

[warning] 40-41: testutil/dataverse_client_mocks.go#L40-L41
Added lines #L40 - L41 were not covered by tests


45-49: LGTM! But add a test for the method.

The method is correctly implemented, but it is not covered by tests.

Consider adding a test to cover this method.

Also applies to: 51-54

Tools
GitHub Check: codecov/patch

[warning] 45-49: testutil/dataverse_client_mocks.go#L45-L49
Added lines #L45 - L49 were not covered by tests


58-61: LGTM! But add a test for the method recorder.

The method recorder is correctly implemented, but it is not covered by tests.

Consider adding a test to cover this method recorder.

Tools
GitHub Check: codecov/patch

[warning] 58-61: testutil/dataverse_client_mocks.go#L58-L61
Added lines #L58 - L61 were not covered by tests

Makefile (2)

82-82: LGTM!

The command is correctly implemented and enhances the testing capabilities.

The code changes are approved.


83-83: LGTM!

The command is correctly implemented and enhances the testing capabilities.

The code changes are approved.

testutil/cognitarium_client_mocks.go (5)

1-11: LGTM!

The file header comments and package declaration are appropriate for an auto-generated file.

The code changes are approved.


12-19: LGTM!

The import statements include necessary packages for context handling, reflection, schema definitions, and mocking utilities.

The code changes are approved.


21-30: LGTM!

The mock struct definitions follow the standard pattern for GoMock-generated code.

The code changes are approved.


32-42: LGTM!

The mock constructor and EXPECT method follow the standard pattern for GoMock-generated code.

The code changes are approved.

Tools
GitHub Check: codecov/patch

[warning] 33-36: testutil/cognitarium_client_mocks.go#L33-L36
Added lines #L33 - L36 were not covered by tests


[warning] 40-41: testutil/cognitarium_client_mocks.go#L40-L41
Added lines #L40 - L41 were not covered by tests


44-122: LGTM!

The mock methods for Construct, Describe, Select, and Store follow the standard pattern for GoMock-generated code. Note that the lack of test coverage is expected for auto-generated code.

The code changes are approved.

Tools
GitHub Check: codecov/patch

[warning] 45-49: testutil/cognitarium_client_mocks.go#L45-L49
Added lines #L45 - L49 were not covered by tests


[warning] 51-54: testutil/cognitarium_client_mocks.go#L51-L54
Added lines #L51 - L54 were not covered by tests


[warning] 58-61: testutil/cognitarium_client_mocks.go#L58-L61
Added lines #L58 - L61 were not covered by tests


[warning] 65-69: testutil/cognitarium_client_mocks.go#L65-L69
Added lines #L65 - L69 were not covered by tests


[warning] 71-74: testutil/cognitarium_client_mocks.go#L71-L74
Added lines #L71 - L74 were not covered by tests


[warning] 78-81: testutil/cognitarium_client_mocks.go#L78-L81
Added lines #L78 - L81 were not covered by tests


[warning] 85-89: testutil/cognitarium_client_mocks.go#L85-L89
Added lines #L85 - L89 were not covered by tests


[warning] 91-94: testutil/cognitarium_client_mocks.go#L91-L94
Added lines #L91 - L94 were not covered by tests


[warning] 98-101: testutil/cognitarium_client_mocks.go#L98-L101
Added lines #L98 - L101 were not covered by tests


[warning] 105-109: testutil/cognitarium_client_mocks.go#L105-L109
Added lines #L105 - L109 were not covered by tests


[warning] 111-114: testutil/cognitarium_client_mocks.go#L111-L114
Added lines #L111 - L114 were not covered by tests


[warning] 118-121: testutil/cognitarium_client_mocks.go#L118-L121
Added lines #L118 - L121 were not covered by tests

dataverse/client.go Show resolved Hide resolved
dataverse/client.go Show resolved Hide resolved
dataverse/client.go Show resolved Hide resolved
testutil/dataverse_mocks.go Show resolved Hide resolved
@bdeneux bdeneux requested review from ccamel and amimart August 26, 2024 13:12
@bdeneux bdeneux self-assigned this Aug 26, 2024
Copy link
Member

@amimart amimart left a comment

Choose a reason for hiding this comment

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

Great :)

Thanks for maintaining the mocks, we gain in testability 💪

Copy link
Member

@ccamel ccamel left a comment

Choose a reason for hiding this comment

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

Great 👍

@bdeneux bdeneux merged commit 30151d4 into main Aug 27, 2024
13 of 14 checks passed
@bdeneux bdeneux deleted the feat/dataverse-get-gov branch August 27, 2024 07:26
@coderabbitai coderabbitai bot mentioned this pull request Oct 12, 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.

3 participants