Skip to content

Commit d41f1ba

Browse files
fix intermittent test failures (#1236)
* fix intermittent test failures * no moar unstable, we don't have wrappers for it so doesn't make sense to test * one more unstable replaced
1 parent aa0b7f9 commit d41f1ba

File tree

4 files changed

+12
-12
lines changed

4 files changed

+12
-12
lines changed

test/clients/base_rest_resource_test.rb

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ def setup
1111
@session = ShopifyAPI::Auth::Session.new(shop: "test-shop.myshopify.com",
1212
access_token: SecureRandom.alphanumeric(10))
1313
@prefix = "https://#{@session.shop}/admin/api/#{ShopifyAPI::Context.api_version}"
14-
ShopifyAPI::Context.load_rest_resources(api_version: "2023-04")
14+
ShopifyAPI::Context.load_rest_resources(api_version: ShopifyAPI::Context.api_version)
1515
end
1616

1717
def test_finds_resource_by_id
@@ -393,10 +393,10 @@ def test_allows_custom_prefixes
393393
end
394394

395395
def test_put_requests_only_modify_changed_attributes
396-
stub_request(:get, "https://test-shop.myshopify.com/admin/api/unstable/products/632910392.json")
396+
stub_request(:get, "https://test-shop.myshopify.com/admin/api/#{ShopifyAPI::Context.api_version}/products/632910392.json")
397397
.to_return(status: 200, body: JSON.generate({ "product" => { "id" => 632910392, "title" => "IPod Nano - 8GB",
398398
"body_html" => "<p>It's the small iPod with one very big idea: Video. Now the world's most popular music player, available in 4GB and 8GB models, lets you enjoy TV shows, movies, video podcasts, and more. The larger, brighter display means amazing picture quality. In six eye-catching colors, iPod nano is stunning all around. And with models starting at just $149, little speaks volumes.</p>", "vendor" => "Apple", "product_type" => "Cult Products", "created_at" => "2023-02-02T09:09:49-05:00", "handle" => "ipod-nano", "updated_at" => "2023-02-02T09:09:49-05:00", "published_at" => "2007-12-31T19:00:00-05:00", "template_suffix" => nil, "status" => "active", "published_scope" => "web", "tags" => "Emotive, Flash Memory, MP3, Music", "admin_graphql_api_id" => "gid://shopify/Product/632910392", "variants" => [{ "id" => 808950810, "product_id" => 632910392, "title" => "Pink", "price" => "199.00", "sku" => "IPOD2008PINK", "position" => 1, "inventory_policy" => "continue", "compare_at_price" => nil, "fulfillment_service" => "manual", "inventory_management" => "shopify", "option1" => "Pink", "option2" => nil, "option3" => nil, "created_at" => "2023-02-02T09:09:49-05:00", "updated_at" => "2023-02-02T09:09:49-05:00", "taxable" => true, "barcode" => "1234_pink", "grams" => 567, "image_id" => 562641783, "weight" => 1.25, "weight_unit" => "lb", "inventory_item_id" => 808950810, "inventory_quantity" => 10, "old_inventory_quantity" => 10, "presentment_prices" => [{ "price" => { "amount" => "199.00", "currency_code" => "USD" }, "compare_at_price" => nil }], "requires_shipping" => true, "admin_graphql_api_id" => "gid://shopify/ProductVariant/808950810" }, { "id" => 49148385, "product_id" => 632910392, "title" => "Red", "price" => "199.00", "sku" => "IPOD2008RED", "position" => 2, "inventory_policy" => "continue", "compare_at_price" => nil, "fulfillment_service" => "manual", "inventory_management" => "shopify", "option1" => "Red", "option2" => nil, "option3" => nil, "created_at" => "2023-02-02T09:09:49-05:00", "updated_at" => "2023-02-02T09:09:49-05:00", "taxable" => true, "barcode" => "1234_red", "grams" => 567, "image_id" => nil, "weight" => 1.25, "weight_unit" => "lb", "inventory_item_id" => 49148385, "inventory_quantity" => 20, "old_inventory_quantity" => 20, "presentment_prices" => [{ "price" => { "amount" => "199.00", "currency_code" => "USD" }, "compare_at_price" => nil }], "requires_shipping" => true, "admin_graphql_api_id" => "gid://shopify/ProductVariant/49148385" }, { "id" => 39072856, "product_id" => 632910392, "title" => "Green", "price" => "199.00", "sku" => "IPOD2008GREEN", "position" => 3, "inventory_policy" => "continue", "compare_at_price" => nil, "fulfillment_service" => "manual", "inventory_management" => "shopify", "option1" => "Green", "option2" => nil, "option3" => nil, "created_at" => "2023-02-02T09:09:49-05:00", "updated_at" => "2023-02-02T09:09:49-05:00", "taxable" => true, "barcode" => "1234_green", "grams" => 567, "image_id" => nil, "weight" => 1.25, "weight_unit" => "lb", "inventory_item_id" => 39072856, "inventory_quantity" => 30, "old_inventory_quantity" => 30, "presentment_prices" => [{ "price" => { "amount" => "199.00", "currency_code" => "USD" }, "compare_at_price" => nil }], "requires_shipping" => true, "admin_graphql_api_id" => "gid://shopify/ProductVariant/39072856" }, { "id" => 457924702, "product_id" => 632910392, "title" => "Black", "price" => "199.00", "sku" => "IPOD2008BLACK", "position" => 4, "inventory_policy" => "continue", "compare_at_price" => nil, "fulfillment_service" => "manual", "inventory_management" => "shopify", "option1" => "Black", "option2" => nil, "option3" => nil, "created_at" => "2023-02-02T09:09:49-05:00", "updated_at" => "2023-02-02T09:09:49-05:00", "taxable" => true, "barcode" => "1234_black", "grams" => 567, "image_id" => nil, "weight" => 1.25, "weight_unit" => "lb", "inventory_item_id" => 457924702, "inventory_quantity" => 40, "old_inventory_quantity" => 40, "presentment_prices" => [{ "price" => { "amount" => "199.00", "currency_code" => "USD" }, "compare_at_price" => nil }], "requires_shipping" => true, "admin_graphql_api_id" => "gid://shopify/ProductVariant/457924702" }], "options" => [{ "id" => 594680422, "product_id" => 632910392, "name" => "Color", "position" => 1, "values" => ["Pink", "Red", "Green", "Black"] }], "images" => [{ "id" => 850703190, "product_id" => 632910392, "position" => 1, "created_at" => "2023-02-02T09:09:49-05:00", "updated_at" => "2023-02-02T09:09:49-05:00", "alt" => nil, "width" => 123, "height" => 456, "src" => "https://cdn.shopify.com/s/files/1/0005/4838/0009/products/ipod-nano.png?v=1675346989", "variant_ids" => [], "admin_graphql_api_id" => "gid://shopify/ProductImage/850703190" }, { "id" => 562641783, "product_id" => 632910392, "position" => 2, "created_at" => "2023-02-02T09:09:49-05:00", "updated_at" => "2023-02-02T09:09:49-05:00", "alt" => nil, "width" => 123, "height" => 456, "src" => "https://cdn.shopify.com/s/files/1/0005/4838/0009/products/ipod-nano-2.png?v=1675346989", "variant_ids" => [808950810], "admin_graphql_api_id" => "gid://shopify/ProductImage/562641783" }, { "id" => 378407906, "product_id" => 632910392, "position" => 3, "created_at" => "2023-02-02T09:09:49-05:00", "updated_at" => "2023-02-02T09:09:49-05:00", "alt" => nil, "width" => 123, "height" => 456, "src" => "https://cdn.shopify.com/s/files/1/0005/4838/0009/products/ipod-nano.png?v=1675346989", "variant_ids" => [], "admin_graphql_api_id" => "gid://shopify/ProductImage/378407906" }], "image" => { "id" => 850703190, "product_id" => 632910392, "position" => 1, "created_at" => "2023-02-02T09:09:49-05:00", "updated_at" => "2023-02-02T09:09:49-05:00", "alt" => nil, "width" => 123, "height" => 456, "src" => "https://cdn.shopify.com/s/files/1/0005/4838/0009/products/ipod-nano.png?v=1675346989", "variant_ids" => [], "admin_graphql_api_id" => "gid://shopify/ProductImage/850703190" }, } }), headers: {})
399-
stub_request(:put, "https://test-shop.myshopify.com/admin/api/unstable/products/632910392.json")
399+
stub_request(:put, "https://test-shop.myshopify.com/admin/api/#{ShopifyAPI::Context.api_version}/products/632910392.json")
400400
.with(
401401
headers: { "X-Shopify-Access-Token" => "this_is_a_test_token", "Accept" => "application/json",
402402
"Content-Type" => "application/json", },
@@ -424,7 +424,7 @@ def test_put_requests_only_modify_changed_attributes
424424
end
425425

426426
def test_put_request_for_has_one_associaiton_works
427-
stub_request(:get, "https://test-shop.myshopify.com/admin/api/unstable/customers/207119551.json")
427+
stub_request(:get, "https://test-shop.myshopify.com/admin/api/#{ShopifyAPI::Context.api_version}/customers/207119551.json")
428428
.to_return(status: 200, body: JSON.generate({ "customer" => { "id" => 207119551,
429429
"email" => "[email protected]", "accepts_marketing" => false, "created_at" => "2023-02-02T09:42:27-05:00", "updated_at" => "2023-02-02T09:42:27-05:00", "first_name" => "Bob", "last_name" => "Norman", "orders_count" => 1, "state" => "disabled", "total_spent" => "199.65", "last_order_id" => 450789469, "note" => nil, "verified_email" => true, "multipass_identifier" => nil, "tax_exempt" => false, "tags" => "L\u00E9on, No\u00EBl", "last_order_name" => "#1001", "currency" => "USD", "phone" => "+16136120707", "addresses" => [{ "id" => 207119551, "customer_id" => 207119551, "first_name" => nil, "last_name" => nil, "company" => nil, "address1" => "Chestnut Street 92", "address2" => "", "city" => "Louisville", "province" => "Kentucky", "country" => "United States", "zip" => "40202", "phone" => "555-625-1199", "name" => "", "province_code" => "KY", "country_code" => "US", "country_name" => "United States", "default" => true }], "accepts_marketing_updated_at" => "2005-06-12T11:57:11-04:00", "marketing_opt_in_level" => nil, "tax_exemptions" => [], "email_marketing_consent" => { "state" => "not_subscribed", "opt_in_level" => nil, "consent_updated_at" => "2004-06-13T11:57:11-04:00" }, "sms_marketing_consent" => { "state" => "not_subscribed", "opt_in_level" => "single_opt_in", "consent_updated_at" => "2023-02-02T09:42:27-05:00", "consent_collected_from" => "OTHER" }, "admin_graphql_api_id" => "gid://shopify/Customer/207119551", "default_address" => { "id" => 207119551, "customer_id" => 207119551, "first_name" => nil, "last_name" => nil, "company" => nil, "address1" => "Chestnut Street 92", "address2" => "", "city" => "Louisville", "province" => "Kentucky", "country" => "United States", "zip" => "40202", "phone" => "555-625-1199", "name" => "", "province_code" => "KY", "country_code" => "US", "country_name" => "United States", "default" => true }, } }), headers: {})
430430

@@ -442,7 +442,7 @@ def test_put_request_for_has_one_associaiton_works
442442
end
443443

444444
def test_put_requests_for_resource_with_read_only_attributes
445-
stub_request(:get, "https://test-shop.myshopify.com/admin/api/unstable/variants/169.json")
445+
stub_request(:get, "https://test-shop.myshopify.com/admin/api/#{ShopifyAPI::Context.api_version}/variants/169.json")
446446
.to_return(
447447
status: 200,
448448
body: JSON.generate(

test/clients/http_client_test.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,7 @@ def test_throttle_error_with_retry_after_header_in_error_object
226226

227227
def test_warns_on_deprecation_header
228228
reader, writer = IO.pipe
229-
modify_context(logger: Logger.new(writer), api_version: "unstable")
229+
modify_context(logger: Logger.new(writer), api_version: "2023-10")
230230
deprecate_reason = "https://help.shopify.com/tutorials#foobar-endpoint-is-removed"
231231
stub_request(@request.http_method, "https://#{@shop}#{@base_path}/#{@request.path}")
232232
.with(body: @request.body.to_json, query: @request.query, headers: @expected_headers)

test/context_test.rb

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ def setup
1212
ShopifyAPI::Context.setup(
1313
api_key: "key",
1414
api_secret_key: "secret",
15-
api_version: "unstable",
15+
api_version: "2023-10",
1616
scope: ["scope1", "scope2"],
1717
is_private: true,
1818
is_embedded: true,
@@ -33,7 +33,7 @@ def test_setup
3333
assert(ShopifyAPI::Context.setup?)
3434
assert_equal("key", ShopifyAPI::Context.api_key)
3535
assert_equal("secret", ShopifyAPI::Context.api_secret_key)
36-
assert_equal("unstable", ShopifyAPI::Context.api_version)
36+
assert_equal("2023-10", ShopifyAPI::Context.api_version)
3737
assert_equal("http://localhost:3000", ShopifyAPI::Context.host)
3838
assert_equal(ShopifyAPI::Auth::AuthScopes.new(["scope1", "scope2"]), ShopifyAPI::Context.scope)
3939
assert(ShopifyAPI::Context.private?)
@@ -115,7 +115,7 @@ def test_with_host_name_and_no_host_env
115115
ShopifyAPI::Context.setup(
116116
api_key: "key",
117117
api_secret_key: "secret",
118-
api_version: "unstable",
118+
api_version: "2023-10",
119119
host_name: "tunnel-o-security.com",
120120
scope: ["scope1", "scope2"],
121121
is_private: true,
@@ -138,7 +138,7 @@ def test_send_a_warning_if_log_level_is_invalid
138138
ShopifyAPI::Context.setup(
139139
api_key: "",
140140
api_secret_key: "",
141-
api_version: "unstable",
141+
api_version: "2023-10",
142142
host_name: "",
143143
scope: [],
144144
is_private: false,
@@ -160,7 +160,7 @@ def clear_context
160160
ShopifyAPI::Context.setup(
161161
api_key: "",
162162
api_secret_key: "",
163-
api_version: "unstable",
163+
api_version: "2023-10",
164164
host_name: "",
165165
scope: [],
166166
is_private: false,

test/test_helper.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ def setup
2626
ShopifyAPI::Context.setup(
2727
api_key: "API_KEY",
2828
api_secret_key: "API_SECRET_KEY",
29-
api_version: "unstable",
29+
api_version: "2023-10",
3030
host: "https://app-address.com",
3131
scope: ["scope1", "scope2"],
3232
is_private: false,

0 commit comments

Comments
 (0)