Skip to content

hook into Mojo::UserAgent::Transactor to validate requests and responses #26

@karenetheridge

Description

@karenetheridge
if ($::DEBUG or $::TESTING) { ...
  my $ua = Mojo::UserAgent
    ->with_roles('something...')
    ->new(
       ...,
       openapi_document => ...,
       validate_requests => 1,
       validate_responses => 0,
       on_request_validation => sub ($request, $result) {
         # log request
         if (not $request) {
           # request failed... fail a test or something...
         }
       },
    );
  $self->ua($ua);
}
$ua->get('/foo/bar');

# and then in your .t file:
$TESTING = 1;
$ua->app($my_test_server);
# run tests... connections go through the test app and requests are validated.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions