-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsystem_test.sh
executable file
·76 lines (63 loc) · 1.59 KB
/
system_test.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
#!/bin/sh
set -a
PATH="$PWD/test/stubs:$PATH"
READ_MESSAGE="$PWD/read_message.awk"
MEMBERS="$PWD/test/etc/mail/members"
ALIASES="$PWD/test/etc/mail/aliases"
MAILDIR="test/home/mail"
WATCHDIR="/dev/null"
LIST_NAME="dev"
RSUB_DIFF_ARGS=" "
function reset {
rm -f etc/*
git checkout $MEMBERS $ALIASES 2> /dev/null
find $MAILDIR/new -type f -exec mv {} $MAILDIR/cur/ \;
}
function try {
printf '.'
expected="test/expected/$(printf "$1" | tr -c '[:alnum:]' '_')"
}
function memberdiff {
for etc in $(find etc -type f); do
diff $etc $MEMBERS
done
}
function check {
git diff --exit-code $expected.* || exit 1
let tests+=1
}
# setup
mkdir -p $MAILDIR/{tmp,new,cur}
mkdir -p etc tmp
try "add list headers"
./add_list_headers.awk < test/opensmtpd-data.in > $expected.out
check
try "read messages"
reset
./read_message.awk test/home/mail/cur/* > $expected.out
check
try "subscribe command"
reset
mv $MAILDIR/cur/1708978889.9004ffbf.hub1.scriptedconfiguration.org:2,RS $MAILDIR/new/
sh -u process-messages.sh > $expected.out
memberdiff > $expected.diff
check
try "unsubscribe command"
reset
echo "[email protected]" >> $MEMBERS
mv $MAILDIR/cur/1718310671.86d68cae.hub1.scriptedconfiguration.org:2,S $MAILDIR/new/
sh -u process-messages.sh > $expected.out
memberdiff > $expected.diff
check
try "status command"
reset
mv $MAILDIR/cur/1718310759.9d6ca6b9.hub1.scriptedconfiguration.org:2,S $MAILDIR/new/
sh -u process-messages.sh > $expected.out
memberdiff > $expected.diff
check
try "no remaining messages"
reset
find $MAILDIR/new -type f > $expected.out
check
echo
echo "$tests tests PASSED"