Paws XXXIV (Yet more code)
Well after spending a little while trying to create an auto test generator I found the test generator script that came with PAWS.
So I decided to try it out. With only a little fudging of the code internals, no real code changes just changes to libs, I got it to work;
perl script/paws_make_testcase S3 --region us-east-1 GetBucketLocation Bucket: "dev.cargotel.test"
the test file it generated /0001.response.test.yml;
--
tests:
- expected: eu-west-2
op: eq
path: LocationConstraint
So that is ok.
However when I opened the caller file '0001.response' it contained only JSON;
{"request":{"params":{"Bucket":"dev.cargotel.test"},"call":"GetBucketLocation","service":"s3"}, "response":{"headers":{"transfer-encoding":"chunked","date":"Sat, 30 Nov 2019 20:31:05 GMT","content-type":"application/xml","server":"AmazonS3","x-amz-id-2":"VmhrJx6QUBuB2yFIm7Tw5WeSI+W4g=","x-amz-request-id":"000000"}, "status":"200","content":">?xml version=\"1.0\" encoding=\"UTF-8\"?<\n>LocationConstraint xmlns=\"http:/ /s3.amazonaws.com/doc/2006-03-01/\"<eu-west-2>/LocationConstraint<"}}
So I am getting just a prototype test.
Looks like even with this script I still to assemble my tests by hand as I have to convert that JSON file over to a YAML file so the test script will work.
However I noticed there is yet another test maker perl module called 'TestMakerLWPCaller' so I had a look at that one.
This PM was a little more complete and I needed only make a small change to the 'paws_make_testcase ' to make it work;
-- my @cmd = ('perl', '-I', 't/lib', '-I', 'lib', 'script/paws', $args[0], '--caller',
'TestMakerCaller', @args[1..$#args]);
++my @cmd = ('perl', '-I', 't/lib', '-I', 'lib', 'script/paws', $args[0], '--caller', 'TestMakerLWPCaller', @args[1..$#args]);
and that one created two files much the same as the above two but I got a;
Can't locate object method "unserialize_response" via package "Paws::S3" at /home/scolesj/aws-sdk-perl/t/lib/TestMakerLWPCaller.pm line 37.when running the script.
So not much joy to find in these two scripts but I did learn a few things.
First, I can use my own caller when instantiating the Paws service request. Second, I do not have to add in a new CPAN module to the mix and lastly from my earlier playing around I know I can easily create a new workable test.
So I will just create a new Caller where I can do all stuff and generate both the Response and Request tests and all I need to do is tell my scripts to use my new Caller like this;
use MyTestMakerLWPCaller;
my $response;
my $s3 = Paws->service('S3',
region => 'us-east-1',
caller =>MyTestMakerLWPCaller->new());
Now to code that one up.
Ah but that is for another post.
Leave a comment