use v5.10.1;
use DBI;
use DBD::SQLite;
+use DBD::SQLite::Constants qw(SQLITE_CONSTRAINT);
use PublicInbox::Over;
use Scalar::Util qw(blessed);
my $sth = $self->{dbh}->prepare_cached(<<'');
INSERT INTO msgmap (mid) VALUES (?)
- return unless eval { $sth->execute($mid) };
+ unless (eval { $sth->execute($mid) }) {
+ return if $self->{dbh}->err == SQLITE_CONSTRAINT;
+ die $@;
+ }
my $num = $self->{dbh}->last_insert_id(undef, undef, 'msgmap', 'num');
$self->num_highwater($num) if defined($num);
$num;
# License: AGPL-3.0+ <https://www.gnu.org/licenses/agpl-3.0.txt>
use v5.12;
use PublicInbox::TestCommon;
+use autodie;
+use Config;
+use PublicInbox::Spawn qw(popen_rd);
require_mods('DBD::SQLite');
use_ok 'PublicInbox::Msgmap';
my ($tmpdir, $for_destroy) = tmpdir();
'ok'
}, 'ok', 'atfork_* work on tmp_clone');
-done_testing();
+SKIP: {
+ my $strace = strace_inject;
+ open my $fh, '>', my $trace = "$tmpdir/trace.out";
+ my $rd = popen_rd([ $strace, '-p', $$, '-o', $trace,
+ '-e', 'inject=pwrite64:error=ENOSPC'], undef, { 2 => 1 });
+ $rd->poll_in(10) or die 'strace not ready';
+ is eval { $d->mid_insert('this-better-trigger-ENOSPC@error') },
+ undef, 'insert fails w/ ENOSPC';
+ like $@, qr/ disk is full/, '$@ reports ENOSPC';
+ kill 'TERM', $rd->attached_pid;
+ $rd->close;
+}
+
+done_testing;
use PublicInbox::Eml;
use PublicInbox::ContentHash qw(content_digest content_hash);
use PublicInbox::TestCommon;
+use PublicInbox::Spawn qw(popen_rd);
+use Config;
use Cwd qw(abs_path);
require_git(2.6);
require_mods(qw(DBD::SQLite Xapian));
is($mode, 0664, sprintf('0%03o', $mode).' is 0664');
}
-done_testing();
+SKIP: {
+ my $strace = strace_inject;
+ my $eml = eml_load 't/plack-qp.eml';
+ open my $fh, '>', my $trace = "$inboxdir/trace.out";
+ my $rd = popen_rd([ $strace, '-p', $$, '-o', $trace,
+ '-e', 'inject=pwrite64:error=ENOSPC'], undef, { 2 => 1 });
+ $rd->poll_in(10) or die 'strace not ready';
+ ok ! eval { $im->add($eml) }, 'v2w->add fails on ENOSPC';
+ like $@, qr/ disk is full/, 'set $@ for ENOSPC';
+ $im->done;
+ kill 'TERM', $rd->attached_pid;
+ $rd->close;
+}
+
+done_testing;