From 1071b8f0631b04dc199e43031e634686ae21e3a0 Mon Sep 17 00:00:00 2001 From: Phillip Davis Date: Tue, 17 Mar 2026 11:44:23 -0400 Subject: [PATCH] what if the network requests fail? --- test/test_bandwidth_tn_repo.rb | 36 ++++++++++------------------------ 1 file changed, 10 insertions(+), 26 deletions(-) diff --git a/test/test_bandwidth_tn_repo.rb b/test/test_bandwidth_tn_repo.rb index c2e40e6aa9f944488d7a80959bbea2b3e6e91e5b..92b980efb552efefe5db82f88c55689c582dcbbc 100644 --- a/test/test_bandwidth_tn_repo.rb +++ b/test/test_bandwidth_tn_repo.rb @@ -109,7 +109,15 @@ class BandwidthTnRepoTest < Minitest::Test [nil, nil, "CA", nil, "NY", "NYC", "CA", "NYC"], [nil, "Austin", nil, "LA", "NY", "NYC", "NY", "Austin"], [nil, nil, nil, "LA", "NY", "NYC", "NY", "LA"], - [nil, nil, nil, nil, "NY", "NYC", "NY", "NYC"] + [nil, nil, nil, nil, "NY", "NYC", "NY", "NYC"], + [:error, :error, "CA", "LA", "NY", "NYC", "CA", "LA"], + [:error, :error, "CA", "2City", "NY", "NYC", "CA", "NYC"], + [:error, :error, "2ST", "2City", "NY", "NYC", "NY", "NYC"], + ["TX", "1City", :error, :error, "NY", "NYC", "TX", "NYC"], + ["1ST", "Austin", :error, :error, "NY", "NYC", "NY", "Austin"], + ["1ST", "1City", :error, :error, "NY", "NYC", "NY", "NYC"], + [nil, nil, :error, :error, "NY", "NYC", "NY", "NYC"], + [:error, :error, :error, :error, "NY", "NYC", "NY", "NYC"] ].each do |bw_r, bw_l, geo_r, geo_l, lcg_r, lcg_l, exp_r, exp_l| WebMock.reset! stub_bw_oauth_token @@ -126,36 +134,12 @@ class BandwidthTnRepoTest < Minitest::Test } }.to_xml - geo_json = { - "latt" => "30.267153", - "longt" => "-97.743061" - } - geo_json["prov"] = geo_r if geo_r - geo_json["city"] = geo_l if geo_l - - stub_request( - :get, - "https://dashboard.bandwidth.com/v1.0/tns/5565555555/tndetails" - ) - .with( - headers: { - "Accept" => "application/xml", - "Accept-Encoding" => "gzip, compressed", - "Authorization" => - "Basic dGVzdF9id191c2VyOnRlc3RfYndfcGFzc3dvcmQ=", - "User-Agent" => "Ruby-Bandwidth-Iris" - } - ).to_return(status: 200, body: bw_body, headers: {}) - stub_request( :get, "https://localcallingguide.com/xmlprefix.php?npa=556&nxx=555" ).to_return(status: 200, body: lcg_body) - stub_request( - :get, - "https://geocoder.ca/?json=1&latt=30.267153&longt=-97.743061" - ).to_return(status: 200, body: geo_json.to_json) + stub_geocoder(geo_r, geo_l) BandwidthTnRepo::DB.expect( :exec,