is_deeply(json_utf8->decode($lei_out), {}, 'no inspect stats, yet');
lei_ok('import', $url);
- lei_ok 'ls-sync';
- like($lei_out, qr!\A\Q$url\E;UIDVALIDITY=\d+\n\z!, 'ls-sync');
+ lei_ok('inspect', $url);
+ my $res = json_utf8->decode($lei_out);
+ is(scalar keys %$res, 1, 'got one key in inspect URL');
+ my $re = qr!\Aimap://;AUTH=ANONYMOUS\@\Q$host_port\E
+ /t\.v2\.0;UIDVALIDITY=\d+!x;
+ like((keys %$res)[0], qr/$re\z/, 'got expanded key');
+
+ lei_ok 'ls-mail-sync';
+ like($lei_out, qr!$re\n\z!, 'ls-mail-sync');
chomp(my $u = $lei_out);
lei_ok('import', $u, \'UIDVALIDITY match in URL');
+ $url = $u;
$u =~ s/;UIDVALIDITY=(\d+)\s*/;UIDVALIDITY=9$1/s;
ok(!lei('import', $u), 'UIDVALIDITY mismatch in URL rejected');
my $inspect = json_utf8->decode($lei_out);
my @k = keys %$inspect;
is(scalar(@k), 1, 'one URL resolved');
- like($k[0], qr!\A\Q$url\E;UIDVALIDITY=\d+\z!, 'inspect URL matches');
+ is($k[0], $url, 'inspect URL matches');
my $stats = $inspect->{$k[0]};
is_deeply([ sort keys %$stats ],
[ qw(uid.count uid.max uid.min) ], 'keys match');
lei_ok('inspect', "blob:$out->[5]->{blob}");
my $x = json_utf8->decode($lei_out);
is(ref($x->{'lei/store'}), 'ARRAY', 'lei/store in inspect');
- is(ref($x->{sync}), 'HASH', 'sync in inspect');
- is(ref($x->{sync}->{$k[0]}), 'ARRAY', 'UID arrays in inspect');
+ is(ref($x->{'mail-sync'}), 'HASH', 'sync in inspect');
+ is(ref($x->{'mail-sync'}->{$k[0]}), 'ARRAY', 'UID arrays in inspect')
+ or diag explain($x);
my $psgi_attach = 'cfa3622cbeffc9bd6b0fc66c4d60d420ba74f60d';
lei_ok('blob', $psgi_attach);
like($lei_out, qr!^Content-Type: multipart/mixed;!sm, 'got full blob');
lei_ok('blob', "$psgi_attach:2");
is($lei_out, "b64\xde\xad\xbe\xef\n", 'got attachment');
+
+ lei_ok 'forget-mail-sync', $url;
+ lei_ok 'ls-mail-sync';
+ unlike($lei_out, qr!\Q$host_port\E!, 'sync info gone after forget');
+ my $uid_url = "$url/;UID=".$stats->{'uid.max'};
+ lei_ok 'import', $uid_url;
+ lei_ok 'inspect', $uid_url;
+ $lei_out =~ /([a-f0-9]{40,})/ or
+ xbail 'inspect missed blob with UID URL';
+ my $blob = $1;
+ lei_ok 'lcat', $uid_url;
+ like $lei_out, qr/^Subject: /sm,
+ 'lcat shows mail text with UID URL';
+ like $lei_out, qr/\bblob:$blob\b/, 'lcat showed blob';
+ my $orig = $lei_out;
+ lei_ok 'lcat', "blob:$blob";
+ is($lei_out, $orig, 'lcat understands blob:...');
+ ok(!lei('lcat', $url), "lcat doesn't work on IMAP URL w/o UID");
});
+
done_testing;