diff --git a/.gitignore b/.gitignore index 470d5a2..7ba24ec 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1 @@ -SOURCES/libpst-0.6.71.tar.gz /libpst-0.6.71.tar.gz diff --git a/tests/data.pst b/tests/data.pst new file mode 100644 index 0000000..8bd5c90 Binary files /dev/null and b/tests/data.pst differ diff --git a/tests/runner.sh b/tests/runner.sh new file mode 100755 index 0000000..b75424e --- /dev/null +++ b/tests/runner.sh @@ -0,0 +1,35 @@ +#!/bin/sh + +case "${1}" in + ("lspst_folders") test "`lspst data.pst | grep -c Folder`" = "5" ;; + ("lspst_mails") test "`lspst data.pst | grep -c Email`" = "3" ;; + ("lspst_contacts") test "`lspst data.pst | grep -c Contact`" = "4" ;; + ("lspst_events") test "`lspst data.pst | grep -c Appointment`" = "1" ;; + ("pst2ldif_run") test "`pst2ldif -b base -c class data.pst | grep -c no.where`" = "3" ;; + ("readpst_basic") test "`readpst data.pst -o /tmp | grep -c Folder`" = "13" ;; + ("readpst_contacts") readpst -tc -cv data.pst >/dev/null && test "`cat Contacts.contacts | grep -c BEGIN:VCARD`" = "3" ;; + ("readpst_contacts_emails") readpst -tc -cv -w data.pst >/dev/null && test "`cat Contacts.contacts | grep -c '@no.where'`" = "3" ;; + ("readpst_contacts_plain") readpst -tc -cl -w data.pst >/dev/null && test "`cat Contacts.contacts | wc -l`" = "3" ;; + ("readpst_contacts_plain_emails") readpst -tc -cl -w >/dev/null data.pst && test "`cat Contacts.contacts | grep -c '@no.where'`" = "3" ;; + ("readpst_events") readpst -ta data.pst >/dev/null && test "`cat Calendar.calendar | grep -c BEGIN:VEVENT`" = "1" ;; + ("readpst_events_summary") readpst -ta -w data.pst >/dev/null && test "`cat Calendar.calendar | grep -c 'SUMMARY:event on 2020-02-13'`" = "1" ;; + ("readpst_mails") readpst -te data.pst >/dev/null && test "`ls -l *.mbox | wc -l`" = "2" ;; + ("readpst_mails_inbox") readpst -te -w data.pst >/dev/null && test "`cat Inbox.mbox | grep -c 'From '`" = "2" ;; + ("readpst_mails_inbox_to") readpst -te -w data.pst >/dev/null && test "`cat Inbox.mbox | grep -c 'To: zyx@no.where'`" = "2" ;; + ("readpst_mails_inbox_cc") readpst -te -w data.pst >/dev/null && test "`cat Inbox.mbox | grep -c -i 'CC'`" = "0" ;; + ("readpst_mails_inbox_email") readpst -te -w data.pst >/dev/null && test "`cat Inbox.mbox | grep -c 'zyx@no.where'`" = "2" ;; + ("readpst_mails_inbox_subject") readpst -te -w data.pst >/dev/null && test "`cat Inbox.mbox | grep -c 'Subject: Plain text message'`" = "2" ;; + ("readpst_mails_inbox_subject_2") readpst -te -w data.pst >/dev/null && test "`cat Inbox.mbox | grep -c 'Subject: Plain text message \]\['`" = "1" ;; + ("readpst_mails_inbox_body") readpst -te -w data.pst >/dev/null && test "`cat Inbox.mbox | grep 'Plain text' | grep -c -v 'Subject:'`" = "1" ;; + ("readpst_mails_inbox_body_2") readpst -te -w data.pst >/dev/null && test "`cat Inbox.mbox | grep -c 'The second plain text'`" = "1" ;; + ("readpst_mails_drafts") readpst -te -w data.pst >/dev/null && test "`cat Drafts.mbox | grep -c 'From '`" = "1" ;; + ("readpst_mails_drafts_to") readpst -te -w data.pst >/dev/null && test "`cat Drafts.mbox | grep -c 'To: zyx@no.where'`" = "1" ;; + ("readpst_mails_drafts_cc") readpst -te -w data.pst >/dev/null && test "`cat Drafts.mbox | grep -c -i 'CC'`" = "0" ;; + ("readpst_mails_drafts_email") readpst -te -w data.pst >/dev/null && test "`cat Drafts.mbox | grep -c 'zyx@no.where'`" = "1" ;; + ("readpst_mails_drafts_subject") readpst -te -w data.pst >/dev/null && test "`cat Drafts.mbox | grep -c 'Subject: Plain text message'`" = "1" ;; + ("readpst_mails_drafts_subject_2") readpst -te -w data.pst >/dev/null && test "`cat Drafts.mbox | grep -c 'Subject: Plain text message \]\['`" = "1" ;; + ("readpst_mails_drafts_body") readpst -te -w data.pst >/dev/null && test "`cat Drafts.mbox | grep 'Plain text' | grep -c -v 'Subject:'`" = "0" ;; + ("readpst_mails_drafts_body_2") readpst -te -w data.pst >/dev/null && test "`cat Drafts.mbox | grep -c 'The second plain text'`" = "1" ;; + ("") echo "runner.sh: Requires one argument, a test name to run" >&2 ; exit 1 ;; + (*) echo "runner.sh: Unknown test name '%{1}'" >&2 ; exit 1 ;; +esac diff --git a/tests/tests.yml b/tests/tests.yml new file mode 100644 index 0000000..504e313 --- /dev/null +++ b/tests/tests.yml @@ -0,0 +1,105 @@ +- hosts: localhost + roles: + - role: standard-test-basic + tags: + - atomic + - classic + required_packages: + - libpst + tests: + - lspst_help: + dir: . + run: lspst -h >/dev/null + - lspst_folders: + dir: . + run: ./runner.sh lspst_folders + - lspst_mails: + dir: . + run: ./runner.sh lspst_mails + - lspst_contacts: + dir: . + run: ./runner.sh lspst_contacts + - lspst_events: + dir: . + run: ./runner.sh lspst_events + - pst2ldif_help: + dir: . + run: pst2ldif -h >/dev/null + - pst2ldif_run: + dir: . + run: ./runner.sh pst2ldif_run + - readpst_help: + dir: . + run: readpst -h >/dev/null + - readpst_basic: + dir: . + run: ./runner.sh readpst_basic + - readpst_contacts: + dir: . + run: ./runner.sh readpst_contacts + - readpst_contacts_emails: + dir: . + run: ./runner.sh readpst_contacts_emails + - readpst_contacts_plain: + dir: . + run: ./runner.sh readpst_contacts_plain + - readpst_contacts_plain_emails: + dir: . + run: ./runner.sh readpst_contacts_plain_emails + - readpst_events: + dir: . + run: ./runner.sh readpst_events + - readpst_events_summary: + dir: . + run: ./runner.sh readpst_events_summary + - readpst_mails: + dir: . + run: ./runner.sh readpst_mails + - readpst_mails_inbox: + dir: . + run: ./runner.sh readpst_mails_inbox + - readpst_mails_inbox_to: + dir: . + run: ./runner.sh readpst_mails_inbox_to + - readpst_mails_inbox_cc: + dir: . + run: ./runner.sh readpst_mails_inbox_cc + - readpst_mails_inbox_email: + dir: . + run: ./runner.sh readpst_mails_inbox_email + - readpst_mails_inbox_subject: + dir: . + run: ./runner.sh readpst_mails_inbox_subject + - readpst_mails_inbox_subject_2: + dir: . + run: ./runner.sh readpst_mails_inbox_subject_2 + - readpst_mails_inbox_body: + dir: . + run: ./runner.sh readpst_mails_inbox_body + - readpst_mails_inbox_body_2: + dir: . + run: ./runner.sh readpst_mails_inbox_body_2 + - readpst_mails_drafts: + dir: . + run: ./runner.sh readpst_mails_drafts + - readpst_mails_drafts_to: + dir: . + run: ./runner.sh readpst_mails_drafts_to + - readpst_mails_drafts_cc: + dir: . + run: ./runner.sh readpst_mails_drafts_cc + - readpst_mails_drafts_email: + dir: . + run: ./runner.sh readpst_mails_drafts_email + - readpst_mails_drafts_subject: + dir: . + run: ./runner.sh readpst_mails_drafts_subject + - readpst_mails_drafts_subject_2: + dir: . + run: ./runner.sh readpst_mails_drafts_subject_2 + - readpst_mails_drafts_body: + dir: . + run: ./runner.sh readpst_mails_drafts_body + - readpst_mails_drafts_body_2: + dir: . + run: ./runner.sh readpst_mails_drafts_body_2