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

refactor(x/data): remove unique constraint on resolver url #1128

Merged
merged 3 commits into from
May 26, 2022

Conversation

ryanchristo
Copy link
Member

@ryanchristo ryanchristo commented May 25, 2022

Description

Closes: #1111

This pull request removes the unique constraint on url and updates query resolver to take the resolver id rather than url.


Author Checklist

All items are required. Please add a note to the item if the item is not applicable and
please add links to any relevant follow up issues.

I have...

  • included the correct type prefix in the PR title
  • added ! to the type prefix if API or client breaking change
  • targeted the correct branch (see PR Targeting)
  • provided a link to the relevant issue or specification
  • followed the guidelines for building modules
  • included the necessary unit and integration tests
  • added a changelog entry to CHANGELOG.md
  • included comments for documenting Go code
  • updated the relevant documentation or specification
  • reviewed "Files changed" and left comments if necessary
  • confirmed all CI checks have passed

Reviewers Checklist

All items are required. Please add a note if the item is not applicable and please add
your handle next to the items reviewed if you only reviewed selected items.

I have...

  • confirmed the correct type prefix in the PR title
  • confirmed ! in the type prefix if API or client breaking change
  • confirmed all author checklist items have been addressed
  • reviewed state machine logic
  • reviewed API design and naming
  • reviewed documentation is accurate
  • reviewed tests and test coverage
  • manually tested (if applicable)

@codecov
Copy link

codecov bot commented May 25, 2022

Codecov Report

Merging #1128 (832c1db) into master (94034cc) will increase coverage by 0.00%.
The diff coverage is 92.30%.

@@           Coverage Diff           @@
##           master    #1128   +/-   ##
=======================================
  Coverage   69.31%   69.32%           
=======================================
  Files         216      216           
  Lines       21948    21908   -40     
=======================================
- Hits        15214    15187   -27     
+ Misses       5407     5389   -18     
- Partials     1327     1332    +5     
Flag Coverage Δ
experimental-codecov 69.24% <92.30%> (+0.06%) ⬆️
stable-codecov 63.51% <92.30%> (-0.01%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

@ryanchristo ryanchristo marked this pull request as ready for review May 25, 2022 01:51
Copy link
Contributor

@aleem1314 aleem1314 left a comment

Choose a reason for hiding this comment

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

lgtm

Copy link
Member

@clevinson clevinson left a comment

Choose a reason for hiding this comment

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

🙏 thank u @ryanchristo !

Just dropped at note in #1111 (comment) echo'ing that I think querying for resolvers by URL with pagination (returning all resolvers with their ID & manager) would be useful. Potentially in a follow-up.

x/data/client/testsuite/grpc.go Outdated Show resolved Hide resolved

Rule: the resolver is defined if the resolver url is unique
Scenario: the url is unique
Copy link
Member

@clevinson clevinson May 25, 2022

Choose a reason for hiding this comment

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

Suggested change
Scenario: the url is unique
Scenario: a resolver for a new url is registered

Copy link
Member Author

Choose a reason for hiding this comment

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

In general, I was thinking the scenario would be short and to the point and the rule would be more descriptive. Given the rule is "the resolver is defined with no unique constraints on the URL", the two scenarios are "the url is unique" and "the url is not unique". This is also how the BDD books write scenarios. For example,

Rule: Any visitor to the website can place a customer-collection order

  Scenario: Unauthenticated customer chooses to collect order
    Given the customer is unauthenticated
    When they choose to collect their order
    Then they should be asked to supply contact details

  Scenario: Authenticated customer chooses to collect order
    Given the customer is authenticated
    When they choose to collect their order
    Then they should be asked to confirm contact details

Copy link
Member Author

Choose a reason for hiding this comment

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

This also produces the test logs:

=== RUN   TestDefineResolver
=== RUN   TestDefineResolver/Define_Resolver
=== RUN   TestDefineResolver/Define_Resolver/a_resolver_for_a_new_url_is_registered
=== RUN   TestDefineResolver/Define_Resolver/a_resolver_is_registered_with_a_url_that_is_already_registered

Versus the current test logs:

=== RUN   TestDefineResolver
=== RUN   TestDefineResolver/Define_Resolver
=== RUN   TestDefineResolver/Define_Resolver/the_url_is_unique
=== RUN   TestDefineResolver/Define_Resolver/the_url_is_not_unique

Copy link
Member Author

Choose a reason for hiding this comment

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

We are also "defining" a resolver here, not "registering" data to the resolver.

Given alice has defined the resolver
When alice attempts to define the resolver
Then expect the error "resolver URL already exists"
Scenario: the url is not unique
Copy link
Member

@clevinson clevinson May 25, 2022

Choose a reason for hiding this comment

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

Suggested change
Scenario: the url is not unique
Scenario: a resolver is registered with a url that is already registered

@ryanchristo
Copy link
Member Author

@clevinson Would be happy to further discuss best format for scenarios and update throughout but the current format is aligned with how I've been writing scenarios elsewhere and I think that if we include a descriptive rule, scenarios should be concise and provide only the necessary information, which makes reading through the test logs easier when debugging failing scenarios.

@ryanchristo ryanchristo merged commit 643fb97 into master May 26, 2022
@ryanchristo ryanchristo deleted the ryan/1111-remove-url-unique branch May 26, 2022 01:41
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.

Restrictions on defining a data resolver URL
3 participants