Skip to content

Commit

Permalink
Test custom template functions
Browse files Browse the repository at this point in the history
  • Loading branch information
ferki committed Aug 27, 2020
1 parent 1fd42ce commit 3f5f30f
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
1 change: 1 addition & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ Revision history for Rex
- Test internal MD5 checksumming methods
- Report coverage to Coveralls
- Add initial test for proc inventory
- Test custom template functions

1.12.1 2020-08-05 Ferenc Erki <[email protected]>
[DOCUMENTATION]
Expand Down
13 changes: 12 additions & 1 deletion t/template.t
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
use strict;
use warnings;

use Test::More tests => 18;
use Test::More tests => 20;

use Rex::Config;
use Rex::Commands;
use Rex::Template;
use Symbol;

my $t = Rex::Template->new;

Expand Down Expand Up @@ -120,3 +121,13 @@ for my $key ( keys %{$v} ) {
);
}

# test custom functions

my $function_name = 'dummy';
my $function_result = $function_name . ' result';

ok( $t->function( $function_name, sub { return $function_result } ),
'registering custom function' );

my $function_ref = qualify_to_ref( $function_name, $t );
is( *{$function_ref}->(), $function_result, 'calling custom function' );

0 comments on commit 3f5f30f

Please sign in to comment.