Conversation
|
Omg yay |
|
This is fantastic. I'm reviewing, should be OK but I just want to familiarize myself with the changes. |
There was a problem hiding this comment.
I don't think we need skip_unless_has_secret anymore.
There was a problem hiding this comment.
We need to keep it because t/07-options.t still needs it. We can't use a mock in the idempotency_key test https://github.com/Crowdtilt/WebService-Stripe/blob/lwp-recorder/t/07-options.t#L17
There was a problem hiding this comment.
Would filter_header => 'Idempotency-Key' solve that? I'm not sure if that affects how LWP Recorder would match a request with a response.
There was a problem hiding this comment.
No, it wouldn't solve it. The problem is that LWP Recorder has no way to differentiate between 2 identical requests. It would only store the response for one of them. That would make mocking this test useless.
This mocks our tests so that a stripe key or network connection will not be necessary to run the tests. This also gives a major speedup. We can still run real tests hitting the actual stripe webservice as we do now, if a stripe api key is provided.
|
The tests run in under 1s now: |
t/lib/Common.pm
Outdated
There was a problem hiding this comment.
I really don't like no_-prefixed variables. Affirmative variables (e.g. mock_lwp => 1) tend to be clearer / less confusing. Suggested rewrite:
memoize 'stripe';
sub stripe {
my %params = @_;
$params{'api_key'} //= api_key;
$params{'version'} //= '2014-12-17';
$params{'mock_lwp_record'} //= $ENV{'PERL_STRIPE_MOCK_RECORD'};
$params{'mock_lwp'} //= $ENV{'PERL_STRIPE_MOCK'}
// !$params{'api_key'};
my %client;
$client{'api_key'} = $params{'api_key'};
$client{'version'} = $params{'version'};
$client{'ua'} = Test::LWP::Recorder->new({
record => $params{'mock_lwp_record'},
cache_dir => 't/LWPCache/' . basename($0),
}) if $params{'mock_lwp'};
state $stripe = WebService::Stripe->new(%client);
return $stripe;
}|
👍 Had a Q about using |
|
We can't merge this until this patch gets accepted riemann42/Test-LWP-Recorder#3 , or the author lets me take over that module, or we aggressively fork it. |
|
Another option is to use this module instead https://metacpan.org/pod/Test::VCR::LWP |
|
That module seems much harder to use suite-wide than the current one. |
This mocks our tests so that a stripe key or network connection will not
be necessary to run the tests. This also gives a major speedup. We can
still run real tests hitting the actual stripe webservice as we do now, if
a stripe api key is provided.