-
Notifications
You must be signed in to change notification settings - Fork 473
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: ShopifyAPI::Webhooks::Registry doesn't update webhooks if metafield_namespaces has changed #1344
Conversation
test/webhooks/registry_test.rb
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In ruby unit tests, is it better to have code be copypaste-ish (like right now)? Or better to introduce logic to make it more elegant? e.g. looping thru each of [http, pubsub, eventbridge], helpers to build the queries we assert on
Pros:
- easier to tell if a specific scenario fails vs one of many scenarios
- less mental overhead (less likely that test logic is buggy and not the actual code)
Cons:
- More code to maintain if these tests become outdated
- looks dumb
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i think these test cases are a little over abstracted. There are a few things I'd recommend to do:
- Rename
webhook_registration_queries.rb
to match the class defined in it. I know this has nothing to do with this PR but it'll help with readability of this file. - I agree with using array to loop through similar test cases
[:http, :pubsub, :eventbridge].each do |protocol|
define_method("test_#{protocol}_registration_is_not_needed_if_identical_webhook_exists") do
# setup helpers
# execution
# assertions
end
end
- Instead of giant
do_....
methods, can we break them down to multiple smaller helpers?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
made the following refactors:
- rename
webhook_registration_queries.rb
toregistry_test_queries.rb
- broke apart
do_registration_test
megafunction tosetup_queries_and_responses
helper,add_and_register_webhook
helper, and assertion statements - looping thru
http
,pub_sub
,event_bridge
(and their valid address formats) to define similar unit tests for those scenarios- also got rid of
do_registration_check_error_test
because there was only one instance of it being called after this
- also got rid of
- consolidated redundant tests
could you take a 2nd lookthru? thanks!
…per for the other tests
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
beautiful! Thank you 💯
TODO:
Description
Fixes #1323
What is the problem it is solving?
What is the context of these changes?
What is the impact of this PR?
Fixing #1323
How has this been tested?
Checklist: