1# GNU Mailutils -- a suite of utilities for electronic mail -*- autotest -*-
2# Copyright (C) 2020-2021 Free Software Foundation, Inc.
3#
4# This library is free software; you can redistribute it and/or modify
5# it under the terms of the GNU Lesser General Public License as published by
6# the Free Software Foundation; either version 3, or (at your option)
7# any later version.
8#
9# This library is distributed in the hope that it will be useful,
10# but WITHOUT ANY WARRANTY; without even the implied warranty of
11# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12# GNU Lesser General Public License for more details.
13#
14# You should have received a copy of the GNU Lesser General Public License
15# along with GNU Mailutils.  If not, see <http://www.gnu.org/licenses/>.
16
17AT_SETUP([Volatile UIDs (traditional MH behavior)])
18
19# Create the test MH mailbox
20AT_CHECK([mbox2dir -m -p -v 10 -u inbox $spooldir/mbox1])
21
22# Check its current UID settings
23AT_CHECK([mbop -m inbox uidnext \; uidvalidity],
24[0],
25[uidnext: 6
26uidvalidity: 10
27])
28
29# Request traditional MH behavior.
30AT_DATA([mh_profile],
31[Volatile-uidnext: true
32])
33
34# Remove the penultimate message.  This should not affect uidvalidity.
35AT_CHECK([MH=mh_profile mbop -m inbox 4 \; set_deleted \; expunge],
36[0],
37[4 current message
384 set_deleted: OK
39expunge: OK
40])
41
42# Check if uidnext and uidvalidity remain the same.
43AT_CHECK([mbop -m inbox uidnext \; uidvalidity],
44[0],
45[uidnext: 6
46uidvalidity: 10
47])
48
49# Remove the last message.  With Volatile-uidnext on, this will reset
50# uidnext to 4 (sequence number of the last message plus one) and
51# increase uidvalidity,
52AT_CHECK([MH=mh_profile mbop -m inbox 4 \; set_deleted \; expunge],
53[0],
54[4 current message
554 set_deleted: OK
56expunge: OK
57])
58
59# Check if uidnext is computed correctly.
60AT_CHECK([MH=mh_profile mbop -m inbox uidnext],
61[0],
62[uidnext: 4
63])
64
65# Check that uidvalidity has changed.
66# FIXME: Better check that it has *increased*.
67AT_CHECK([MH=mh_profile mbop -m inbox uidvalidity | grep -v '^uid-validity:10$' | grep uid-validity || true])
68
69AT_CLEANUP
70
71
72
73