Skip to content
This repository has been archived by the owner on Nov 28, 2024. It is now read-only.

Integration test suite #2

Open
ivy opened this issue Dec 6, 2017 · 10 comments
Open

Integration test suite #2

ivy opened this issue Dec 6, 2017 · 10 comments

Comments

@ivy
Copy link

ivy commented Dec 6, 2017

As it stands now, there are only unit tests that mock the behavior but don't actually interact with an SMTP server. I believe we can merge with more confidence if we can start testing against a locally running server.

@pedromorgan
Copy link

Maybe this https://github.com/mailhog/MailHog

@ivy
Copy link
Author

ivy commented Dec 6, 2017

No, this needs to be a real MTA or we risk missing important differences in widely deployed implementations. MailHog looks like a helpful UI for local development.

@marcusva
Copy link

marcusva commented Apr 13, 2018

Docker comes to mind with something like the following setup:

  • one container containing go-mail including a test application sending out 1-N mails covering go-mail's feature set
  • one container running an SMTP server receiving mails and storing them into a mbox- or maildir-based inbox

The test script would start up both containers e.g. via docker-compose, wait for the mails to be sent and stored (simple approach: wait X seconds) and compares the stored mails against the expected set of mails.

The latter would need to be created beforehand, though, with some important points to consider:

  • timestamp mismatches in the headers
  • sender/receiver information (IP) mismatches
  • other header mismatches

The comparison might be done using the mbox format (two files to compare) with the necessity to filter out variable parts, as mentioned before.

A more complex approach might be to parse the stored mails and just evaluate certain portions, such as

  • From, To, Bcc, Sender
  • Subject
  • Body
  • multipart content
  • other go-mail configurable message settings

against the predefined set of information. This might be accomplished with reasonable effort using e.g. Python's email package (or third-party libraries).

The advantage of the second approach is that the input data could be kept external and used for both, feeding the mail producer as well as the comparison script. This also would reduce the maintenance efforts for the test scenarios.

Since docker can be run within a Travis-CI environment, this also lets one test pull requests and other code changes against the integration test suite without any additional effort.

@pedromorgan
Copy link

@marcusva I got a couple of virtuals on machines here so docker would be neat. One runs postfix, one is google proxy config, and a souple of exchange server (spits) etc.. mainly to test our clients systems..

@pedromorgan
Copy link

it all runs on fabfile script at the moment.. but checking against real machines in a way..

@james-lawrence
Copy link

@ivy on a related note, library should expose the current mocking functionality (maybe from a subpackage) we've run into a bug were partial emails are delivered in the original library but no way to really reproduce without copying a bunch of code from the library.

@ivy
Copy link
Author

ivy commented Sep 14, 2018

@james-lawrence Interesting, were you able to find out the cause? Do you think better debug logging would have helped in your case?

@james-lawrence
Copy link

yes, the cause is assets for the email being unavialable during the creation of the email and the email contents are written directly to the transport layer. so if anything goes wrong a partial email is sent.

@james-lawrence
Copy link

james-lawrence commented Sep 14, 2018

debug logging is immaterial here, it was more an issue with writing a test to prevent regressions.

when I said reproduce, I mean in tests, not in the actual system.

@phamdt
Copy link

phamdt commented Nov 25, 2019

@ivy i'd be curious to know what mailhog is lacking for testing. i'm using it myself for testing features that use go-mail and want to make sure there's not some sort of case that needs more attention.

diamondburned pushed a commit to diamondburned/gomail that referenced this issue Aug 21, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants