Skip to content
Snippets Groups Projects
Commit 0fce77f8 authored by Jakub Cegan's avatar Jakub Cegan
Browse files

(task 613) Upravy skriptu a pridani testu

parent d4569374
No related branches found
No related tags found
No related merge requests found
#!/usr/bin/perl
use strict;
use warnings;
use DBI;
use DBD::mysql;
use Data::Dumper;
use Test::More tests => 7;
use Test::MockModule;
use Test::Exception;
use lib '..';
use wardenWatchdog;
my (%input, $retCode, $result);
print "== wardenWatchdog::send_report ==\n";
*wardenWatchdog::sendmail_wrapper = sub {print "sendmailWrapper is set to broken!\nSending of emails will fail\n"; return 0;};
%input = (contact => 'test@test.receiver.cz', domain => 'test.domain.cz', text => 'TEST MSG!');
($retCode, $result) = wardenWatchdog::send_report(\%input);
ok ($retCode == 0, 'Broken sendmail');
*wardenWatchdog::sendmail_wrapper = sub {print "sendmailWrapper is OFF!\nSending of emails is blocked\n"; return 1;};
%input = (contact => '', domain => 'test.domain.cz', text => 'TEST MSG!');
($retCode, $result) = wardenWatchdog::send_report(\%input);
ok ($retCode == 0, 'No contact');
%input = (contact => 'test@test.receiver.cz', domain => '', text => 'TEST MSG!');
($retCode, $result) = wardenWatchdog::send_report(\%input);
ok ($retCode == 0, 'No domain');
%input = (contact => '', domain => 'test.domain.cz', text => '');
($retCode, $result) = wardenWatchdog::send_report(\%input);
ok ($retCode == 0, 'No text');
%input = (contact => 'test@test.receiver.cz', domain => 'test.domain.cz', text => 'TEST MSG!');
($retCode, $result) = wardenWatchdog::send_report(\%input);
ok ($retCode == 1, 'All OK');
print "== wardenWatchdog::connect_to_DB ==\n";
my $dbh;
($retCode, $result) = connect_to_DB(\$dbh);
ok ($retCode == 1, 'Connected to the DB');
# FAILED DB CONNECTION
print "== wardenWatchdog::update_procedures ==\n";
# CORRECT RUN OF update_procedures
print "== wardenWatchdog::send_query ==\n";
# RUN WITH BROKEN DB CONNECTION
# RUN WITH NO query
# CORRECT RUN OF send_query
print "== wardenWatchdog::run ==\n";
# RUN WITHOUT domain
# RUN WITHOUT period
# CORRECT RUN OF send_query
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment