Skip to content

Commit

Permalink
Suppress warnings by encoding undef value
Browse files Browse the repository at this point in the history
  • Loading branch information
moznion committed Mar 17, 2014
1 parent 9ee8367 commit 27c35ee
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 1 deletion.
8 changes: 7 additions & 1 deletion lib/Ukigumo/Server/Command/Report.pm
Expand Up @@ -250,7 +250,13 @@ sub find {
sub _compress_text_data {
my ($self, $row) = @_;
c->config->{enable_compression} or return $row;
$row->{$_} = __compress($row->{$_}) for qw(vc_log body);

for my $type (qw/vc_log body/) {
if (defined(my $content_text = $row->{$type})) {
$row->{$type} = __compress($content_text);
}
}

$row;
}

Expand Down
19 changes: 19 additions & 0 deletions t/03-compression.t
Expand Up @@ -100,4 +100,23 @@ subtest "multibytes" => sub {
ok utf8::is_utf8($report->{vc_log});
};

subtest "with no warnings of Encode.pm" => sub {
my $warned = 0;
local $SIG{__WARN__} = sub {
$warned++;
};

$c->config->{enable_compression} = 1;

my $id = Ukigumo::Server::Command::Report->insert(
project => 'MyProj',
branch => 'master',
status => 1,
);

my $row = $c->db->single('report', { report_id => $id })->get_columns;

ok !$warned;
};

done_testing;

0 comments on commit 27c35ee

Please sign in to comment.