From 9a34a9557b5e22de9a7dfab03224d0864639cb98 Mon Sep 17 00:00:00 2001 From: FBnil Date: Sun, 7 Apr 2024 01:28:18 +0200 Subject: [PATCH] Changed the range and filter functions, needed new way of testing --- test/test-evidencer.pl | 35 +++++++++++++++++++++++++++++++---- 1 file changed, 31 insertions(+), 4 deletions(-) diff --git a/test/test-evidencer.pl b/test/test-evidencer.pl index 21faa8d..2652733 100755 --- a/test/test-evidencer.pl +++ b/test/test-evidencer.pl @@ -275,12 +275,34 @@ sub execute{ @_ = execute("$exe $cfg TEST2=VM-PR-DMZ\@BACK -Dvd |grep -i look "); say @_; - is($#_,3-1,'three lines - named '); - like($_[0], qr/no$/, 'Primary does not match'); - like($_[1], qr/yes$/, 'Backup matches 1'); - like($_[2], qr/yes$/, 'Backup matches 2'); + is($#_,1-1,'one line - named hosts'); + like($_[0], qr{2/3}, 'Primary does not match'); + like($_[0], qr/2 matched/, 'Backup matches 2 servers'); + like($_[0], qr/match BACK/, 'We are matching BACK'); }; +subtest 'Named hosts with range' => sub { + plan tests => 8; + + @_ = execute("$exe $cfg TEST2=VM-PR-DMZ\@BACK#2 -Dvd |grep -i -e look -e From "); + say @_; + is($#_,2-1,'two lines - named hosts range'); + like($_[0], qr{2/3}, 'Two matches'); + like($_[1], qr/1 matched/, 'Backup matches 1 servers'); + like($_[0], qr/match BACK/, 'We are matching BACK'); + + @_ = execute("$exe $cfg TEST2=VM-PR-DMZ\@BACK#-1 -Dvd |grep -i -e look -e From "); + say @_; + like($_[0], qr{2/3}, 'Two matches'); + like($_[1], qr/1 matched/, 'Backup matches 1 servers'); + + @_ = execute("$exe $cfg TEST2=VM-PR-DMZ\@#1--1 -Dvd |grep -i -e look -e From "); + say @_; + like($_[0], qr{3/3}, 'Three matches'); + like($_[1], qr/3 matched/, 'Backup matches 3 servers'); +}; + + subtest 'MAXMATCHES' => sub { plan tests => 8; @@ -355,6 +377,8 @@ sub execute{ plan tests => 21; ok( open(my $EFH, '<', $exe) , 'read $exe globlize' ); my @code; + # https://www.aplawrence.com/Words2005/2005_06_12.html + # https://perlhacks.com/2014/01/dots-perl/ while(<$EFH>) { push( @code, $_ ) if /sub globlize/ .. /\}/; } @@ -371,3 +395,6 @@ sub execute{ }; done_testing(); + + +