pledgecamp / pledgecamp-mail-tester

Capture Mailgun API calls and render emails for testing.
0 stars 0 forks source link

Add unit tests #7

Closed sampullman closed 3 years ago

sampullman commented 3 years ago

Add unit tests in a test folder. Use Golang common practices/libraries.

A test for the db issue solved in #2 would be a good one, along with simpler tests such as:

The db connection test can be ported from this python script:

import asyncio

import requests

async def post_mail() -> None:
    post_mail_loop = asyncio.get_event_loop()
    futures = [
        post_mail_loop.run_in_executor(
            None,
            requests.post,
            'http://mail-test.localdev.com:4020/api/messages',
            {
                'from': 'from@example.com',
                'to': 'to@example.com',
                'subject': 'subject',
                'text': 'text',
                'html': 'html',
            },
        )
        for _ in range(2**8)
    ]
    await asyncio.gather(*futures)

loop = asyncio.get_event_loop()
loop.run_until_complete(post_mail())