2 # Copyright (C) 2021 all contributors <meta@public-inbox.org>
3 # License: AGPL-3.0+ <https://www.gnu.org/licenses/agpl-3.0.txt>
4 use PublicInbox::TestCommon;
5 require_ok 'PublicInbox::MdirReader';
6 *maildir_basename_flags = \&PublicInbox::MdirReader::maildir_basename_flags;
7 *maildir_path_flags = \&PublicInbox::MdirReader::maildir_path_flags;
9 is(maildir_basename_flags('foo'), '', 'new valid name accepted');
10 is(maildir_basename_flags('foo:2,'), '', 'cur valid name accepted');
11 is(maildir_basename_flags('foo:2,bar'), 'bar', 'flags name accepted');
12 is(maildir_basename_flags('.foo:2,bar'), undef, 'no hidden files');
13 is(maildir_basename_flags('fo:o:2,bar'), undef, 'no extra colon');
14 is(maildir_path_flags('/path/to/foo:2,S'), 'S', 'flag returned for path');
15 is(maildir_path_flags('/path/to/.foo:2,S'), undef, 'no hidden paths');
16 is(maildir_path_flags('/path/to/foo:2,'), '', 'no flags in path');
18 # not sure if there's a better place for eml_from_path
19 use_ok 'PublicInbox::InboxWritable', qw(eml_from_path);
20 is(eml_from_path('.'), undef, 'eml_from_path fails on directory');
22 is_deeply([PublicInbox::MdirReader::flags2kw('S')], [{ 'seen' => 1 }, []],
23 "`seen' kw set from flag");
24 is_deeply([PublicInbox::MdirReader::flags2kw('Su')], [{ 'seen' => 1 }, ['u']],
25 'unknown flag ignored');