Skip to content

Commit

Permalink
Merge pull request #1966 from Clinical-Genomics/feature/fixing_test_c…
Browse files Browse the repository at this point in the history
…overage

Feature/fixing test coverage
  • Loading branch information
jemten committed Oct 13, 2021
2 parents 131c6e0 + aea41eb commit db2e89f
Show file tree
Hide file tree
Showing 4 changed files with 113 additions and 4 deletions.
2 changes: 1 addition & 1 deletion lib/MIP/Main/Qccollect.pm
Expand Up @@ -38,7 +38,7 @@ BEGIN {
our $VERSION = q{2.1.10};

# Functions and variables which can be optionally exported
our @EXPORT_OK = qw{ mip_qccollect };
our @EXPORT_OK = qw{ mip_qccollect parse_limit_qc_output };
}

sub mip_qccollect {
Expand Down
22 changes: 21 additions & 1 deletion t/analysis_variant_annotation.t
Expand Up @@ -47,7 +47,7 @@ diag( q{Test analysis_variant_annotation from Variant_annotation.pm}
. $SPACE
. $EXECUTABLE_NAME );

my $log = test_log( { log_name => q{MIP}, no_screen => 1, } );
test_log( { log_name => q{MIP}, no_screen => 1, } );

## Given analysis parameters
my $recipe_name = q{variant_annotation};
Expand Down Expand Up @@ -109,4 +109,24 @@ my $is_ok = analysis_variant_annotation(
## Then return TRUE
ok( $is_ok, q{ Executed analysis recipe } . $recipe_name );

## Given no loqusdb file in toml - alters the bcftools command
$active_parameter{vcfanno_config} =
catfile( $Bin, qw{ data references grch37_vcfanno_config_bad_template-v1.0-.toml } );

$is_ok = analysis_variant_annotation(
{
active_parameter_href => \%active_parameter,
case_id => $case_id,
file_info_href => \%file_info,
job_id_href => \%job_id,
parameter_href => \%parameter,
profile_base_command => $slurm_mock_cmd,
recipe_name => $recipe_name,
sample_info_href => \%sample_info,
}
);

## Then still return TRUE
ok( $is_ok, q{ Executed analysis recipe } . $recipe_name );

done_testing();
6 changes: 4 additions & 2 deletions t/parse_containers.t
Expand Up @@ -20,7 +20,7 @@ use Modern::Perl qw{ 2018 };
## MIPs lib/
use lib catdir( dirname($Bin), q{lib} );
use MIP::Constants qw{ $COMMA $SPACE };
use MIP::Test::Fixtures qw{ test_mip_hashes };
use MIP::Test::Fixtures qw{ test_log test_mip_hashes };

BEGIN {

Expand All @@ -30,7 +30,7 @@ BEGIN {
## Modules with import
my %perl_module = (
q{MIP::Environment::Container} => [qw{ parse_containers }],
q{MIP::Test::Fixtures} => [qw{ test_mip_hashes }],
q{MIP::Test::Fixtures} => [qw{ test_log test_mip_hashes }],
);

test_import( { perl_module_href => \%perl_module, } );
Expand All @@ -46,6 +46,8 @@ diag( q{Test parse_containers from Container.pm}
. $SPACE
. $EXECUTABLE_NAME );

test_log( {} );

my %active_parameter = test_mip_hashes(
{
mip_hash_name => q{active_parameter},
Expand Down
87 changes: 87 additions & 0 deletions t/parse_limit_qc_output.t
@@ -0,0 +1,87 @@
#! /usr/bin/env perl

use 5.026;
use Carp;
use charnames qw{ :full :short };
use English qw{ -no_match_vars };
use File::Basename qw{ dirname };
use File::Spec::Functions qw{ catdir };
use FindBin qw{ $Bin };
use open qw{ :encoding(UTF-8) :std };
use Params::Check qw{ allow check last_error };
use Test::More;
use utf8;
use warnings qw{ FATAL utf8 };

## CPANM
use autodie qw { :all };
use Modern::Perl qw{ 2018 };

## MIPs lib/
use lib catdir( dirname($Bin), q{lib} );
use MIP::Constants qw{ $COMMA $SPACE };

BEGIN {

use MIP::Test::Fixtures qw{ test_import };

### Check all internal dependency modules and imports
## Modules with import
my %perl_module = ( q{MIP::Main::Qccollect} => [qw{ parse_limit_qc_output }], );

test_import( { perl_module_href => \%perl_module, } );
}

use MIP::Main::Qccollect qw{ parse_limit_qc_output };

diag( q{Test parse_limit_qc_output from Qccollect.pm}
. $COMMA
. $SPACE . q{Perl}
. $SPACE
. $PERL_VERSION
. $SPACE
. $EXECUTABLE_NAME );

## Given a qc data hash
my %qc_data = (
sample => {
sample_id => {
recipe_output_file => {
collectmultiplemetrics => {
header => q{data},
},
},
another_file => {
collecthsmetrics => {
header => q{data},
},
},
},
},
);

## When executing sub
parse_limit_qc_output(
{
limit_qc_output => 1,
qc_href => \%qc_data,
}
);

## Then remove key collectmultiplemetrics
my %expected_qc_data = (
sample => {
sample_id => {
recipe_output_file => {},
another_file => {
collecthsmetrics => {
header => q{data},
},
},
},
},
);

is_deeply( \%qc_data, \%expected_qc_data, q{Delete qc data from hash} );

done_testing();

0 comments on commit db2e89f

Please sign in to comment.