From 77591ad357f28be9a727710a1dfc5e044a459000 Mon Sep 17 00:00:00 2001 From: dakkar Date: Sat, 28 Jan 2006 11:14:52 +0000 Subject: pipeline fatte e testate, forse fix #2 git-svn-id: svn://luxion/repos/WebCoso/trunk@142 fcb26f47-9200-0410-b104-b98ab5b095f3 --- t/03-pipeline.t | 32 +++++++++++++++++++++++++------- t/lib/WebCoso/Pipeline/Test.pm | 5 ++++- t/lib/WebCoso/Step/Step1.pm | 11 ++++++----- t/lib/WebCoso/Step/Step2.pm | 13 +++++++------ 4 files changed, 42 insertions(+), 19 deletions(-) (limited to 't') diff --git a/t/03-pipeline.t b/t/03-pipeline.t index 0095596..85b769c 100644 --- a/t/03-pipeline.t +++ b/t/03-pipeline.t @@ -21,15 +21,33 @@ WebCoso::Driver->run(); my @resources=WebCoso::Config->get_all_resources(); -my @calls1=WebCoso::Step::Step1->get_calls(); -is(scalar @calls1,1,"1 chiamata a Step1"); +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'); - -my @calls2=WebCoso::Step::Step2->get_calls(); -is(scalar @calls2,1,"1 chiamata a Step2"); + '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'); + '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)'); diff --git a/t/lib/WebCoso/Pipeline/Test.pm b/t/lib/WebCoso/Pipeline/Test.pm index 2d13d69..8c339ff 100644 --- a/t/lib/WebCoso/Pipeline/Test.pm +++ b/t/lib/WebCoso/Pipeline/Test.pm @@ -3,7 +3,10 @@ use strict; use warnings; use base 'WebCoso::Pipeline::Base'; -__PACKAGE__->set_steps(qw(Step1 Step2)); +__PACKAGE__->set_steps( + Step1 => {p1 => 1}, + Step2 => {p2 => 2} +); my @calls; diff --git a/t/lib/WebCoso/Step/Step1.pm b/t/lib/WebCoso/Step/Step1.pm index 8a36d1d..9b18d16 100644 --- a/t/lib/WebCoso/Step/Step1.pm +++ b/t/lib/WebCoso/Step/Step1.pm @@ -1,24 +1,25 @@ package WebCoso::Step::Step1; +use base 'WebCoso::Step::Base'; use strict; use warnings; -my @calls; - sub process { - my ($class,$resource)=@_; + my ($self,$resource,$stage)=@_; my $out='stuff'; - push @calls,{ + push @{$self->{calls}},{ resource => $resource, out_res => $out, + stage => $stage, }; return $out; } sub get_calls { - return @calls; + my ($self)=@_; + return @{$self->{calls}}; } 1; diff --git a/t/lib/WebCoso/Step/Step2.pm b/t/lib/WebCoso/Step/Step2.pm index 0868842..0a45e3c 100644 --- a/t/lib/WebCoso/Step/Step2.pm +++ b/t/lib/WebCoso/Step/Step2.pm @@ -1,24 +1,25 @@ package WebCoso::Step::Step2; +use base 'WebCoso::Step::Base'; use strict; use warnings; -my @calls; - sub process { - my ($class,$resource)=@_; + my ($self,$resource,$stage)=@_; - my $out='other'; + my $out='stuff'; - push @calls,{ + push @{$self->{calls}},{ resource => $resource, out_res => $out, + stage => $stage, }; return $out; } sub get_calls { - return @calls; + my ($self)=@_; + return @{$self->{calls}}; } 1; -- cgit v1.2.3