use strict;
use warnings;
use Path::Class;
use Test::More 'no_plan';
use Test::Exception;
use lib 't/lib';
use WebCoso::Config;
use WebCoso::Driver;
use WebCoso::Pipeline::Test;
my $thisdir=file($0)->parent->absolute;
my $conf_file=<<'EOF';
res('src/file1.rest.txt','Test','dst/file.html');
EOF
WebCoso::Config->read_scalar($conf_file,"$thisdir/config-in-test");
WebCoso::Driver->run();
my @resources=WebCoso::Config->get_all_resources();
my @calls1=WebCoso::Pipeline::Test->_steps()->[0]->get_calls();
is(scalar @calls1,2,"2 chiamata a Step1");
is($calls1[0]->{resource},
$resources[0],
'risorsa giusta passata a Step1(1)');
is($calls1[1]->{resource},
$resources[0],
'risorsa giusta passata a Step1(2)');
is($calls1[0]->{stage},
'meta',
'stage1==meta (step1)');
is($calls1[1]->{stage},
'gen',
'stage2==gen (step1)');
my @calls2=WebCoso::Pipeline::Test->_steps()->[1]->get_calls();
is(scalar @calls2,2,"2 chiamata a Step2");
is($calls2[0]->{resource},
$calls1[0]->{out_res},
'risorsa giusta passata a Step2(1)');
is($calls2[1]->{resource},
$calls1[1]->{out_res},
'risorsa giusta passata a Step2(2)');
is($calls2[0]->{stage},
'meta',
'stage1==meta (step2)');
is($calls2[1]->{stage},
'gen',
'stage2==gen (step2)');