|
10 | 10 | config.transport.transport_class = Sentry::DummyTransport
|
11 | 11 | end
|
12 | 12 | end
|
| 13 | + |
| 14 | + before do |
| 15 | + stub_request(:post, Sentry::TestHelper::DUMMY_DSN) |
| 16 | + end |
| 17 | + |
13 | 18 | subject(:client) { Sentry::Client.new(configuration) }
|
14 | 19 |
|
15 | 20 | let(:hub) do
|
|
470 | 475 | before do
|
471 | 476 | configuration.background_worker_threads = 0
|
472 | 477 | Sentry.background_worker = Sentry::BackgroundWorker.new(configuration)
|
| 478 | + |
| 479 | + stub_request(:post, "http://sentry.localdomain/sentry/api/42/envelope/") |
| 480 | + .to_raise(Timeout::Error) |
473 | 481 | end
|
474 | 482 |
|
475 | 483 | it "swallows and logs Sentry::ExternalError (caused by transport's networking error)" do
|
476 | 484 | expect(client.capture_event(event, scope)).to be_nil
|
477 | 485 |
|
478 |
| - expect(string_io.string).to match(/Event sending failed: Failed to open TCP connection/) |
479 |
| - expect(string_io.string).to match(/Event capturing failed: Failed to open TCP connection/) |
| 486 | + expect(string_io.string).to match(/Event sending failed: Exception from WebMock/) |
| 487 | + expect(string_io.string).to match(/Event capturing failed: Exception from WebMock/) |
480 | 488 | end
|
481 | 489 |
|
482 | 490 | it "swallows and logs errors caused by the user (like in before_send)" do
|
|
502 | 510 | context "when sending events in background causes error", retry: 3 do
|
503 | 511 | before do
|
504 | 512 | Sentry.background_worker = Sentry::BackgroundWorker.new(configuration)
|
| 513 | + |
| 514 | + stub_request(:post, "http://sentry.localdomain/sentry/api/42/envelope/") |
| 515 | + .to_raise(Timeout::Error) |
505 | 516 | end
|
506 | 517 |
|
507 | 518 | it "swallows and logs Sentry::ExternalError (caused by transport's networking error)" do
|
508 | 519 | expect(client.capture_event(event, scope)).to be_a(Sentry::ErrorEvent)
|
509 | 520 | sleep(0.2)
|
510 | 521 |
|
511 |
| - expect(string_io.string).to match(/Event sending failed: Failed to open TCP connection/) |
| 522 | + expect(string_io.string).to match(/Event sending failed: Exception from WebMock/) |
512 | 523 | end
|
513 | 524 |
|
514 | 525 | it "swallows and logs errors caused by the user (like in before_send)" do
|
|
560 | 571 | describe "#send_event" do
|
561 | 572 | context "error happens when sending the event" do
|
562 | 573 | it "raises the error" do
|
| 574 | + stub_request(:post, "http://sentry.localdomain/sentry/api/42/envelope/") |
| 575 | + .to_raise(Timeout::Error) |
| 576 | + |
563 | 577 | expect do
|
564 | 578 | client.send_event(event)
|
565 | 579 | end.to raise_error(Sentry::ExternalError)
|
566 | 580 |
|
567 |
| - expect(string_io.string).to match(/Event sending failed: Failed to open TCP connection/) |
| 581 | + expect(string_io.string).to match(/Event sending failed: Exception from WebMock/) |
568 | 582 | end
|
569 | 583 | end
|
570 | 584 |
|
|
635 | 649 | end
|
636 | 650 |
|
637 | 651 | it "records lost span delta client reports" do
|
| 652 | + stub_request(:post, "http://sentry.localdomain/sentry/api/42/envelope/") |
| 653 | + .to_raise(Timeout::Error) |
| 654 | + |
638 | 655 | expect { client.send_event(transaction_event) }.to raise_error(Sentry::ExternalError)
|
639 | 656 | expect(client.transport).to have_recorded_lost_event(:before_send, 'span', num: 2)
|
640 | 657 | end
|
|
0 commit comments