Commit 0876cc3b 0876cc3b84f02011dc0f962fe2832853c07c6574 by Sergey Poznyakoff

New file. Tests for message saving and disposing commands: delete, mbox, [sS]ave, [wW]rite

1 parent 1b5bfc5e
# -*- tcl -*-
# This file is part of Mailutils testsuite.
# Copyright (C) 2002, Free Software Foundation
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software Foundation,
# Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
mail_start "--file=%mbox1"
# Delete first and last message and quit
mail_command "delete 1 4"
mail_test -noprompt "quit" \
"Held 2 messages in $MAIL_SPOOL_DIR/mbox1"
# Start again using the same mailbox
mail_start -reuse-spool "--file=%mbox1"
mail_test "h" \
">U 1 Bar Fri Dec 28 23:28 16/579 Re: Jabberwocky"\
" U 2 Sergey Poznyakoff Sat Jul 13 00:43 44/1645 Simple MIME"
# Send first message to mbox...
mail_command "mbox 1"
mail_test "h" \
">M 1 Bar Fri Dec 28 23:28 16/579 Re: Jabberwocky"\
" U 2 Sergey Poznyakoff Sat Jul 13 00:43 44/1645 Simple MIME"
# ... and quit
mail_test -noprompt "quit" \
"Saved 1 messages in $MAIL_SPOOL_DIR/mbox" \
"Held 1 messages in $MAIL_SPOOL_DIR/mbox1"
# Now check the mbox contents
mail_start -reuse-spool "--file=%mbox"
mail_test "headers" \
">N 1 Sergey Poznyakoff Sun Jul 16 12:11 12/429 MBOX"\
" U 2 Bar Fri Dec 28 23:28 16/579 Re: Jabberwocky"
# Save messages to the third mailbox
mail_command "set folder=\"$MAIL_FOLDER_DIR\""
mail_test "save 1 2 +three" \
"\"$MAIL_FOLDER_DIR/three\" 28/1008 "
mail_test "headers" \
">* 1 Sergey Poznyakoff Sun Jul 16 12:11 12/429 MBOX"\
" * 2 Bar Fri Dec 28 23:28 16/579 Re: Jabberwocky"
mail_test -noprompt "quit" \
"Held 0 messages in $MAIL_SPOOL_DIR/mbox"
# Examine its contents
mail_start -reuse-spool "--file=$MAIL_FOLDER_DIR/three"
mail_test "headers" \
">N 1 Sergey Poznyakoff Sun Jul 16 12:11 12/429 MBOX"\
" U 2 Bar Fri Dec 28 23:28 16/579 Re: Jabberwocky"
# Test uppercase commands (Save and Copy)
mail_command "set outfolder=\"$MAIL_FOLDER_DIR\""
mail_test "Save" \
"\"$MAIL_FOLDER_DIR/gray\" 12/429 "
mail_test "file \"$MAIL_FOLDER_DIR/gray\"" \
"Held 1 messages in $MAIL_FOLDER_DIR/three"
mail_test "headers" \
">N 1 Sergey Poznyakoff Sun Jul 16 12:11 12/429 MBOX"
mail_exit
# Test write
mail_start -reuse-spool "--file=%teaparty.mbox"
mail_command "set outfolder=\"$MAIL_FOLDER_DIR\""
mail_test "write" \
"\"$MAIL_FOLDER_DIR/1\" 1/15 "
mail_test "write 2 3 tmp" \
"\"$MAIL_FOLDER_DIR/tmp\" 2/37 "
mail_test "Write 1 2 3" \
"\"$MAIL_FOLDER_DIR/hare\" 3/52 "
mail_exit
# Now examine the created files
mail_test_file "$MAIL_FOLDER_DIR/1" "Have some wine"
mail_test_file "$MAIL_FOLDER_DIR/tmp" \
"I don't see any wine" \
"There isn't any"
mail_test_file "$MAIL_FOLDER_DIR/hare" \
"Have some wine" \
"I don't see any wine" \
"There isn't any"