Skip to content

Commit

Permalink
Fix flaky tests
Browse files Browse the repository at this point in the history
SSLPoster was leaking changes in state to other tests
  • Loading branch information
jenshenny committed May 1, 2024
1 parent 1b1e01d commit 1c8199d
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion test/unit/posts_data_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
require 'active_support/core_ext/class'

class PostsDataTest < Minitest::Test

class SSLPoster
include PostsData

Expand Down Expand Up @@ -44,6 +43,8 @@ def test_logger_warns_if_ssl_strict_disabled

SSLPoster.ssl_strict = false
@poster.raw_ssl_request(:post, "https://shopify.com", "", {})
ensure
SSLPoster.ssl_strict = true
end

def test_logger_warns_can_handle_non_string_endpoints
Expand All @@ -65,10 +66,15 @@ def test_logger_no_warning_if_ssl_strict_enabled
end

def test_set_proxy_address_and_port
original_proxy_address = SSLPoster.proxy_address
original_proxy_port = SSLPoster.proxy_port
SSLPoster.proxy_address = 'http://proxy.example.com'
SSLPoster.proxy_port = '8888'
assert_equal @poster.proxy_address, 'http://proxy.example.com'
assert_equal @poster.proxy_port, '8888'
ensure
SSLPoster.proxy_address = original_proxy_address
SSLPoster.proxy_port = original_proxy_port
end

class HttpConnectionAbort < StandardError; end
Expand Down

0 comments on commit 1c8199d

Please sign in to comment.