Updated mcollective.init according to OSCI-658
[packages/precise/mcollective.git] / ext / action_helpers / perl / t / basic.t
1 #!perl
2 use strict;
3 use Test::More;
4 use JSON;
5 use File::Temp;
6
7 my $class = "MCollective::Action";
8 use_ok( $class );
9
10 my $infile  = File::Temp->new;
11 my $outfile = File::Temp->new;
12
13 $ENV{MCOLLECTIVE_REQUEST_FILE} = $infile->filename;
14 $ENV{MCOLLECTIVE_REPLY_FILE}   = $outfile->filename;
15 print $infile JSON->new->encode({ red => "apples", blue => "moon" });
16 close $infile;
17 {
18     my $mc = $class->new;
19     isa_ok( $mc, $class );
20     is( $mc->request->{red}, "apples", "apples are red" );
21     $mc->reply->{potato} = "chips";
22 }
23
24 my $json = do { local $/; <$outfile> };
25 ok( $json, "Got some JSON" );
26 my $reply = JSON->new->decode( $json );
27
28 is( $reply->{potato}, "chips", "Got the reply that potato = chips" );
29
30 done_testing();