-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #875 from Clinical-Genomics/feature/test_function_…
…hash Feature/test function hash
- Loading branch information
Showing
4 changed files
with
338 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,113 @@ | ||
#!/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{ 2017 }; | ||
use Readonly; | ||
|
||
## MIPs lib/ | ||
use lib catdir( dirname($Bin), q{lib} ); | ||
use MIP::Constants qw{ $COMMA $SPACE }; | ||
use MIP::Test::Fixtures qw{ test_standard_cli }; | ||
|
||
my $VERBOSE = 1; | ||
our $VERSION = 1.00; | ||
|
||
$VERBOSE = test_standard_cli( | ||
{ | ||
verbose => $VERBOSE, | ||
version => $VERSION, | ||
} | ||
); | ||
|
||
BEGIN { | ||
|
||
use MIP::Test::Fixtures qw{ test_import }; | ||
|
||
### Check all internal dependency modules and imports | ||
## Modules with import | ||
my %perl_module = ( | ||
q{MIP::Test::Commands} => [qw{ build_call }], | ||
q{MIP::Test::Fixtures} => [qw{ test_standard_cli }], | ||
); | ||
|
||
test_import( { perl_module_href => \%perl_module, } ); | ||
} | ||
|
||
use MIP::Test::Commands qw{ build_call }; | ||
|
||
diag( q{Test build_call from Commands.pm v} | ||
. $MIP::Test::Commands::VERSION | ||
. $COMMA | ||
. $SPACE . q{Perl} | ||
. $SPACE | ||
. $PERL_VERSION | ||
. $SPACE | ||
. $EXECUTABLE_NAME ); | ||
|
||
## Given scalar input (input_value) | ||
my $argument = q{jedi}; | ||
my $input_value = q{luke}; | ||
my %required_argument = ( darth_vader => { input => q{sith_lord}, }, ); | ||
|
||
my @scalar_args = build_call( | ||
{ | ||
argument => $argument, | ||
input_value => $input_value, | ||
required_argument_href => \%required_argument, | ||
} | ||
); | ||
my @expected_scalar_args = qw{ darth_vader sith_lord jedi luke }; | ||
|
||
## Then built call should be returned | ||
is_deeply( \@scalar_args, \@expected_scalar_args, q{Built scalar args} ); | ||
|
||
## Given array input (input_values_ref) | ||
my @input_values = qw{ luke obi-wan }; | ||
|
||
my @array_args = build_call( | ||
{ | ||
argument => $argument, | ||
input_values_ref => \@input_values, | ||
required_argument_href => \%required_argument, | ||
} | ||
); | ||
|
||
my @expected_array_args = ( qw{ darth_vader sith_lord jedi }, \@input_values ); | ||
|
||
## Then built call should be returned with array ref | ||
is_deeply( \@array_args, \@expected_array_args, q{Built array args} ); | ||
|
||
## Given hash input (input_value_href) | ||
my %input_value_hash = ( | ||
luke => q{padawan}, | ||
q{obi-wan} => q{master}, | ||
); | ||
|
||
my @hash_args = build_call( | ||
{ | ||
argument => $argument, | ||
input_value_href => \%input_value_hash, | ||
required_argument_href => \%required_argument, | ||
} | ||
); | ||
|
||
my @expected_hash_args = ( qw{ darth_vader sith_lord jedi }, \%input_value_hash ); | ||
|
||
## Then built call should be returned with array ref | ||
is_deeply( \@hash_args, \@expected_hash_args, q{Built hash args} ); | ||
|
||
done_testing(); |
Oops, something went wrong.