You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

82 lines
2.0 KiB

  1. #!/usr/bin/env bats
  2. # needs:
  3. # bash-bats
  4. #
  5. # run with:
  6. # bats --tap test_mw.bats
  7. run_only_test() {
  8. if [ "$BATS_TEST_NUMBER" -ne "$1" ]; then
  9. skip
  10. fi
  11. }
  12. setup()
  13. {
  14. #run_only_test 4
  15. XDG_CONFIG_HOME=mwtesttmp/config \
  16. MAILDIR=mwtesttmp/share/mail \
  17. XDG_CACHE_HOME=mwtesttmp/cache \
  18. source ../bin/mw
  19. export NOTMUCH_CONFIG=mwtesttmp/config/notmuch-config
  20. export mwrealname="real name"
  21. export mwfulladdr="full.addr@gmail.com"
  22. export mwlogin="$mwfulladdr"
  23. export mwshare=$PWD/../share
  24. function pass() { return 0; }
  25. export pass
  26. }
  27. teardown()
  28. {
  29. if [ -z "$TEST_FUNCTION" ]
  30. then
  31. rm -rf mwtesttmp
  32. fi
  33. }
  34. #1
  35. @test "check config" {
  36. [ "$mwmbsyncrc" = "mwtesttmp/config/isync/mbsyncrc" ]
  37. [ "$mwmsmtprc" = "mwtesttmp/config/msmtp/config" ]
  38. }
  39. #2
  40. @test "add online" {
  41. export mwtype=online
  42. run mwadd
  43. [ -f mwtesttmp/config/mutt/muttrc ]
  44. [ -d mwtesttmp/config/mutt/accounts ]
  45. [ "$(cat mwtesttmp/config/isync/mbsyncrc | sed -ne '/^\s*\w/p')" = "" ]
  46. [ "$(cat mwtesttmp/config/msmtp/config | sed -ne '/^account/p')" = "" ]
  47. [ ! -f mwtesttmp/config/notmuch-config ]
  48. }
  49. #3
  50. @test "add offline unsuccessful" {
  51. export mwtype=offline
  52. export mwmaxmes="0"
  53. run mwadd
  54. [ -f mwtesttmp/config/mutt/muttrc ]
  55. [ -d mwtesttmp/config/mutt/accounts ]
  56. [ "$(cat mwtesttmp/config/isync/mbsyncrc | sed -ne '/^\s*\w/p')" = "" ]
  57. [ "$(cat mwtesttmp/config/msmtp/config | sed -ne '/^account/p')" = "" ]
  58. [ ! -f mwtesttmp/config/notmuch-config ]
  59. }
  60. #4
  61. @test "add offline successfully" {
  62. export mwtype=offline
  63. export mwmaxmes="0"
  64. export mailboxes="[Gmail]/Drafts"
  65. run mwadd
  66. [ -f mwtesttmp/config/mutt/muttrc ]
  67. [ -d mwtesttmp/config/mutt/accounts ]
  68. [ -f mwtesttmp/config/notmuch-config ]
  69. cat mwtesttmp/config/isync/mbsyncrc | sed -ne '/^\s*\w/p'
  70. [ ! "$(cat mwtesttmp/config/isync/mbsyncrc | sed -ne '/^\s*\w/p')" = "" ]
  71. [ ! "$(cat mwtesttmp/config/msmtp/config | sed -ne '/^account/p')" = "" ]
  72. }