in reply to OK to Include CHI File Data in module Tests ?

I started out using an in-memory driver for CHI and pre-warmed that with a few requests and this worked but liked the idea of injecting at the User Agent level. After a little wrangling with the Mojo::UserAgent classes which are a little new to me I ended up working out how to inject the HTTP response with a little help from Sub::OverRide . Essentially in my test scripts I can now just inject a response like so:
my $override3 = Sub::Override->new('Mojo::Transaction::res', sub { my $res2 = Mojo::Message::Response->new ; $res2->code( 200 ); $res2->body( "TESTED FINE" ); return $res2; });

I also came across Mojo::UserAgent::Mockable but it took quite a while to install and seemed to introduce a lot of new dependencies so I put that on the backburner - may be worth a look at again in the future.

It also allows you to continue with new overrides as you progress but one little thing that caught me out was that each override needs to be assigned to a distinct variable and you cannot re-use the same one. I expect that this could be avoided by blocking each instance as described in the docs but the approach I'm using now serves my needs well.

As I continue to work at improving my test writing I'll def. use this injection approach or a refinement of it going forward.