Skip to content

Commit

Permalink
remove only instance of check error test to abstract less
Browse files Browse the repository at this point in the history
  • Loading branch information
andy-liuu committed Nov 4, 2024
1 parent 1fd2e90 commit a0c039d
Showing 1 changed file with 25 additions and 26 deletions.
51 changes: 25 additions & 26 deletions test/webhooks/registry_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,31 @@ def setup
end

define_method("test_raises_on_#{protocol}_registration_check_error_with_address_#{address}") do
do_registration_check_error_test(protocol, address)
# Given
ShopifyAPI::Webhooks::Registry.clear
body = { query: queries[protocol][:check_query], variables: nil }

stub_request(:post, @url)
.with(body: JSON.dump(body))
.to_return(status: 304)

# When
ShopifyAPI::Webhooks::Registry.add_registration(
topic: @topic,
delivery_method: protocol,
path: address,
handler: TestHelpers::FakeWebhookHandler.new(
lambda do |topic, shop, body|
end,
),
)

# Then
assert_raises(StandardError) do
ShopifyAPI::Webhooks::Registry.register_all(
session: @session,
)
end
end
end
end
Expand Down Expand Up @@ -409,31 +433,6 @@ def do_registration_test(
assert_equal(expected_update_webhook_response, update_registration_response.body)
end

def do_registration_check_error_test(delivery_method, path)
ShopifyAPI::Webhooks::Registry.clear
body = { query: queries[delivery_method][:check_query], variables: nil }

stub_request(:post, @url)
.with(body: JSON.dump(body))
.to_return(status: 304)

ShopifyAPI::Webhooks::Registry.add_registration(
topic: @topic,
delivery_method: delivery_method,
path: path,
handler: TestHelpers::FakeWebhookHandler.new(
lambda do |topic, shop, body|
end,
),
)

assert_raises(StandardError) do
ShopifyAPI::Webhooks::Registry.register_all(
session: @session,
)
end
end

def add_and_register_webhook(protocol, address, fields: nil, metafield_namespaces: nil)
ShopifyAPI::Webhooks::Registry.add_registration(
topic: @topic,
Expand Down

0 comments on commit a0c039d

Please sign in to comment.