Skip to content

Commit e64d7f8

Browse files
committed
added tests
1 parent eb50e47 commit e64d7f8

File tree

2 files changed

+21
-17
lines changed

2 files changed

+21
-17
lines changed

t/lib/TestMethod/Base.pm

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,14 @@ sub make_test_dir {
3333
sub make_test_env {
3434
my $self = shift;
3535
my $workflow = shift;
36+
my $args = shift || [];
3637

37-
MooseX::App::ParsedArgv->new( argv => [ "run", "--workflow", $workflow ] );
38+
my $init_args = [ "run", "--workflow", $workflow ];
39+
if($args && ref($args) eq 'ARRAY'){
40+
map { push (@{$init_args}, $_) } @{$args};
41+
}
42+
43+
MooseX::App::ParsedArgv->new( argv => $init_args );
3844

3945
my $test = BioX::Workflow::Command->new_with_command();
4046

t/lib/TestsFor/BioX/Workflow/Command/run/Test009.pm

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,8 @@ extends 'TestMethod::Base';
2020
=head1 Purpose
2121
2222
This tests references -
23-
https://github.com/biosails/BioX-Workflow-Command/issues/12 The special HPC var
24-
supports arrays and hashes, but it wasn't properly dealt with when they were
25-
mixed and matched
23+
https://github.com/biosails/BioX-Workflow-Command/issues/19 Refactoring the
24+
'check_sample_exists' function didn't add the samples to the global samples attr
2625
2726
=cut
2827

@@ -37,24 +36,22 @@ sub write_test_file {
3736
{ root_dir => 'data/analysis' },
3837
{ indir => 'data/raw' },
3938
{ outdir => 'data/processed' },
40-
{jellyfish_dir => 'data/JELLYFISH/{$sample}/jellyfish'},
39+
{ jellyfish_dir => 'data/analysis/{$sample}/jellyfish' },
4140
{ find_sample_bydir => 1 },
4241
{ by_sample_outdir => 1 },
43-
{ HPC => [{account => 'gencore'}] },
42+
{ HPC => [ { account => 'gencore' } ] },
4443
],
4544
rules => [
4645
{
4746
pre_assembly_jellyfish_count => {
4847
'local' => [
4948
{ root_dir => 'data/raw' },
50-
{ outdir => '{$self->jellyfish_dir}' },
51-
# { outdir => 'data/THING' },
49+
{ outdir => '{$self->jellyfish_dir}' },
5250
{
53-
INPUT =>
54-
'{$self->jellyfish_dir}/some_input_rule1'
51+
INPUT => '{$self->jellyfish_dir}/some_input_rule1'
5552
},
56-
{ OUTPUT => '{$self->jellyfish_dir}/some_input_rule1' },
57-
{ HPC => [{'deps' => 'some_dep'}]}
53+
{ OUTPUT => '{$self->jellyfish_dir}/some_input_rule1' },
54+
{ HPC => [ { 'deps' => 'some_dep' } ] }
5855
],
5956
process =>
6057
'R1: INDIR: {$self->indir} INPUT: {$self->INPUT} outdir: {$self->outdir} OUTPUT: {$self->OUTPUT}',
@@ -77,10 +74,11 @@ sub write_test_file {
7774
sub construct_tests {
7875
my $test_methods = TestMethod::Base->new();
7976
my $test_dir = $test_methods->make_test_dir();
77+
8078
write_test_file($test_dir);
8179

82-
my $t = "$test_dir/conf/test1.1.yml";
83-
my $test = $test_methods->make_test_env($t);
80+
my $t = "$test_dir/conf/test1.1.yml";
81+
my $test = $test_methods->make_test_env( $t, [ '--samples', 'Sample_01' ] );
8482
my $rules = $test->workflow_data->{rules};
8583

8684
return ( $test, $test_dir, $rules );
@@ -97,13 +95,13 @@ sub test_001 {
9795
}
9896

9997
$test->post_process_rules;
100-
is_deeply($test->samples, ['Sample_01']);
98+
is_deeply( $test->samples, ['Sample_01'] );
99+
100+
ok((-d 'data/analysis/Sample_01/jellyfish'));
101101

102-
diag(Dumper(system("tree data")));
103102
ok(1);
104103
}
105104

106-
107105
sub _init_rule {
108106
my $test = shift;
109107
my $rule = shift;

0 commit comments

Comments
 (0)