X-Git-Url: https://review.fuel-infra.org/gitweb?a=blobdiff_plain;f=ext%2Faction_helpers%2Fperl%2Ft%2Fbasic.t;fp=ext%2Faction_helpers%2Fperl%2Ft%2Fbasic.t;h=4717efb524291bf21c4fca693f2c19752af1d5dd;hb=b87d2f4e68281062df1913440ca5753ae63314a9;hp=0000000000000000000000000000000000000000;hpb=ab0ea530b8ac956091f17b104ab2311336cfc250;p=packages%2Fprecise%2Fmcollective.git diff --git a/ext/action_helpers/perl/t/basic.t b/ext/action_helpers/perl/t/basic.t new file mode 100644 index 0000000..4717efb --- /dev/null +++ b/ext/action_helpers/perl/t/basic.t @@ -0,0 +1,30 @@ +#!perl +use strict; +use Test::More; +use JSON; +use File::Temp; + +my $class = "MCollective::Action"; +use_ok( $class ); + +my $infile = File::Temp->new; +my $outfile = File::Temp->new; + +$ENV{MCOLLECTIVE_REQUEST_FILE} = $infile->filename; +$ENV{MCOLLECTIVE_REPLY_FILE} = $outfile->filename; +print $infile JSON->new->encode({ red => "apples", blue => "moon" }); +close $infile; +{ + my $mc = $class->new; + isa_ok( $mc, $class ); + is( $mc->request->{red}, "apples", "apples are red" ); + $mc->reply->{potato} = "chips"; +} + +my $json = do { local $/; <$outfile> }; +ok( $json, "Got some JSON" ); +my $reply = JSON->new->decode( $json ); + +is( $reply->{potato}, "chips", "Got the reply that potato = chips" ); + +done_testing();