Sentry-SDK
view release on metacpan or search on metacpan
t/cgi-application-plugin-sentry.t view on Meta::CPAN
use Mojo::Base -strict;
use Mojo::File;
# curfile missing in Mojolicious@^8. The dependency shall not be updated for
# the time being. For this reason `curfile` is duplicated for now.
# use lib curfile->sibling('lib')->to_string;
# See https://github.com/mojolicious/mojo/blob/4093223cae00eb516e38f2226749d2963597cca3/lib/Mojo/File.pm#L36
use lib Mojo::File->new(Cwd::realpath((caller)[1]))->sibling('lib')->to_string;
use CGI;
use Capture::Tiny qw(capture);
use Mock::Mojo::UserAgent;
use Mojo::Util 'dumper';
use Sentry::Hub;
use Test::Spec;
$CGI::USE_PARAM_SEMICOLONS = 0;
{
package My::Application;
use Mojo::Base 'CGI::Application', -signatures;
use CGI::Application::Plugin::Sentry;
sub cgiapp_init ($self) {
$self->param(
sentry_options => {
dsn =>
'http://ff21cbe6ddaf4314833eabd2075e38e3@example.com/foo/bar/2',
traces_sample_rate => 1
}
);
}
sub cgiapp_prerun ($self, $rm) {
Sentry::SDK->configure_scope(sub ($scope) {
$scope->set_tags({ bla => 'blubb' });
});
}
sub setup ($self) {
$self->start_mode('mode1');
$self->run_modes('mode1' => \&mode1);
}
sub mode1 {
Sentry::SDK->capture_message('hello');
return 'abc';
}
}
describe 'CGI::Application::Plugin::Sentry' => sub {
my $app;
my $http;
before each => sub {
$http = Mock::Mojo::UserAgent->new;
$app = My::Application->new;
my $client = Sentry::Hub->get_current_hub->client;
$client->_transport->_http($http);
};
describe 'GET mode1' => sub {
my $out;
my $err;
( run in 0.567 second using v1.01-cache-2.11-cpan-140bd7fdf52 )