datawookie/emayili

Fix failing tests

datawookie opened this issue · 1 comments

When @ColinFay runs the test suite the following tests failed. These tests pass on my local machine and also in GitHub Actions. We need to improve the tests so that they are more robust. Specifically:

  • test for {cld2} or {cld3} being installed
  • enforce consistent timezone and
  • conditionally test SSL (can we do this with another service, not Gmail)?
> devtools::test()
ℹ Loading emayili
ℹ Testing emayili
✔ |  OK F W S | Context
✔ |   2       | address-parts                                                                                
✔ |  27       | address [0.2 s]                                                                              
✔ |   5       | attachment                                                                                   
✔ |  17       | body [0.2 s]                                                                                 
✔ |  11       | compliant [0.5 s]                                                                            
✔ |   2       | display                                                                                      
✔ |  11       | encoding [0.1 s]                                                                             
✔ |  12       | envelope [0.2 s]                                                                             
✖ |   4 1     | header-language [1.9 s]                                                                      
─────────────────────────────────────────────────────────────────────────────────────────────────────────────
Error (test-header-language.R:21:3): detect language
Error: Unable to auto-detect language. Install {cld3} or {cld2}.
Backtrace:
 1. testthat::expect_match(...) test-header-language.R:21:2
 6. emayili::as.character.envelope(.)
 8. emayili::as.character.MIME(body) /Users/colin/git/github/colinfay/emayili/R/envelope.R:127:4
 9. emayili::content_language(x$language, x$content) /Users/colin/git/github/colinfay/emayili/R/mime.R:322:2
─────────────────────────────────────────────────────────────────────────────────────────────────────────────
✔ |   8       | header-precedence                                                                            
✖ |  16 2     | header-various [0.1 s]                                                                       
─────────────────────────────────────────────────────────────────────────────────────────────────────────────
Failure (test-header-various.R:12:3): set expires & reply-by
envelope\(\) %>% expires\("2030-01-01 13:25:00", "UTC"\) %>% expires\(\) does not match "Tue, 01 Jan 2030 13:25:00 \\+0000 \\(UTC|GMT\\)".
Actual value: "Tue, 01 Jan 2030 14:25:00 \+0100 \(CET\)"
Backtrace:
 1. testthat::expect_match(...) test-header-various.R:12:2
 2. testthat:::expect_match_(...)

Failure (test-header-various.R:16:3): set expires & reply-by
envelope\(\) %>% replyby\("2021-12-25 06:00:00", "GMT"\) %>% replyby\(\) does not match "Sat, 25 Dec 2021 06:00:00 \\+0000 \\(UTC|GMT\\)".
Actual value: "Sat, 25 Dec 2021 07:00:00 \+0100 \(CET\)"
Backtrace:
 1. testthat::expect_match(...) test-header-various.R:16:2
 2. testthat:::expect_match_(...)
─────────────────────────────────────────────────────────────────────────────────────────────────────────────
✔ |   3       | header [0.1 s]                                                                               
✔ |   1       | message [0.1 s]                                                                              
✔ |  21       | mime [0.4 s]                                                                                 
✔ |   2       | parties [0.1 s]                                                                              
✔ |   1       | raw [0.1 s]                                                                                  
✔ |  10       | recipients [0.2 s]                                                                           
✔ |   3       | render-cache                                                                                 
✔ |  13       | render [13.2 s]                                                                              
✔ |   2       | sanitise                                                                                     
✖ |  15 1     | server [32.5 s]                                                                              
─────────────────────────────────────────────────────────────────────────────────────────────────────────────
Failure (test-server.R:45:3): sends with SSL
`smtp_gmail(msg %>% subject("{emayili} test"))` threw an error.
Message: Request failed after 5 attempts
Class:   purrr_error_rate_excess/rlang_error/error/condition
Backtrace:
 1. testthat::expect_error(...) test-server.R:45:2
 6. emayili:::smtp_gmail(msg %>% subject("{emayili} test"))
 7. purrr:::send_mail(...) /Users/colin/git/github/colinfay/emayili/R/server.R:130:4
 8. purrr::rate_sleep(rate, quiet = quiet)
 9. purrr:::stop_rate_excess(rate)
─────────────────────────────────────────────────────────────────────────────────────────────────────────────
✔ |   3       | subject                                                                                      
✔ |  19       | utils                                                                                        

══ Results ══════════════════════════════════════════════════════════════════════════════════════════════════
Duration: 51.0 s

[ FAIL 4 | WARN 0 | SKIP 0 | PASS 208 ]

Hi @ColinFay, I think I have cleared up this issue now. Would you mind trying the tests in the test-ssl branch locally on your machine? Thanks, Andrew.