Skip to content

Commit

Permalink
Add basic integration test
Browse files Browse the repository at this point in the history
  • Loading branch information
barisbalic committed Apr 28, 2016
1 parent e70405f commit 3b808cc
Show file tree
Hide file tree
Showing 6 changed files with 129 additions and 0 deletions.
27 changes: 27 additions & 0 deletions test/integration/adapters/mailgun_test.exs
@@ -0,0 +1,27 @@
defmodule Swoosh.Integration.MailgunAdapterTest do
use ExUnit.Case, async: true

alias Swoosh.Adapters.Mailgun
import Swoosh.Email

@moduletag external: true

test "Mailgun Adapter" do
sandbox_domain = System.get_env("MAILGUN_SANDBOX_DOMAIN")

config = %{domain: sandbox_domain, api_key: System.get_env("MAILGUN_API_KEY")}

email =
%Swoosh.Email{}
|> from("Mailgun Test <mailgun@#{sandbox_domain}>")
|> reply_to("mailgun@#{sandbox_domain}")
|> to("leafybasil+swoosh@gmail.com")
|> cc("leafybasil+swooshcc@gmail.com")
|> bcc("leafybasil+swooshbcc@gmail.com")
|> subject("Mailgun integration test")
|> text_body("Hey, just testing!")
|> html_body("<h1>Hey, just <i>testing!</i></h1>")

assert {:ok, response} = Swoosh.Adapters.Mailgun.deliver(email, config)
end
end
25 changes: 25 additions & 0 deletions test/integration/adapters/mandrill_test.exs
@@ -0,0 +1,25 @@
defmodule Swoosh.Integration.MandrillAdapterTest do
use ExUnit.Case, async: true

alias Swoosh.Adapters.Mandrill
import Swoosh.Email

@moduletag external: true

test "Mandrill Adapter" do
config = %{api_key: System.get_env("MANDRILL_API_KEY")}

email =
%Swoosh.Email{}
|> from("steve@stevedomin.com")
|> reply_to("mandrill@test.com")
|> to("leafybasil+swoosh@gmail.com")
|> cc("leafybasil+swooshcc@gmail.com")
|> bcc("leafybasil+swooshbcc@gmail.com")
|> subject("Mandrill integration test")
|> text_body("Hey, just testing!")
|> html_body("<h1>Hey, just <i>testing!</i></h1>")

assert {:ok, response} = Swoosh.Adapters.Mandrill.deliver(email, config)
end
end
25 changes: 25 additions & 0 deletions test/integration/adapters/postmark_test.exs
@@ -0,0 +1,25 @@
defmodule Swoosh.Integration.PostmarkAdapterTest do
use ExUnit.Case, async: true

alias Swoosh.Adapters.Postmark
import Swoosh.Email

@moduletag external: true

test "Postmark Adapter" do
config = %{api_key: System.get_env("POSTMARK_API_KEY")}

email =
%Swoosh.Email{}
|> from("Postmark Test <admin@playr.io>")
|> reply_to("leafybasil+swoosh@gmail.com")
|> to("leafybasil+swoosh@gmail.com")
|> cc("leafybasil+swooshcc@gmail.com")
|> bcc("leafybasil+swooshbcc@gmail.com")
|> subject("Postmark integration test")
|> text_body("Hey, just testing!")
|> html_body("<h1>Hey, just <i>testing!</i></h1>")

assert {:ok, response} = Swoosh.Adapters.Postmark.deliver(email, config)
end
end
25 changes: 25 additions & 0 deletions test/integration/adapters/sendgrid_test.exs
@@ -0,0 +1,25 @@
defmodule Swoosh.Integration.SendgridAdapterTest do
use ExUnit.Case, async: true

alias Swoosh.Adapters.Sendgrid
import Swoosh.Email

@moduletag external: true

test "Sendgrid Adapter" do
config = %{api_key: System.get_env("SENDGRID_API_KEY")}

email =
%Swoosh.Email{}
|> from("Sendgrid Test <test@sendgrid.com>")
|> reply_to("test@#sendgrid.com")
|> to("leafybasil+swoosh@gmail.com")
|> cc("leafybasil+swooshcc@gmail.com")
|> bcc("leafybasil+swooshbcc@gmail.com")
|> subject("Sendgrid integration test")
|> text_body("Hey, just testing!")
|> html_body("<h1>Hey, just <i>testing!</i></h1>")

assert {:ok, response} = Swoosh.Adapters.Sendgrid.deliver(email, config)
end
end
26 changes: 26 additions & 0 deletions test/integration/adapters/smtp_test.exs
@@ -0,0 +1,26 @@
defmodule Swoosh.Integration.SMTPTest do
use ExUnit.Case, async: true

alias Swoosh.Adapters.Sendgrid
import Swoosh.Email

@moduletag external: true

test "Sendgrid Adapter" do
config = %{relay: System.get_env("SMTP_RELAY"), username: System.get_env("SMTP_USERNAME"),
password: System.get_env("SMTP_PASSWORD")}

email =
%Swoosh.Email{}
|> from("SMTP Test <test@smtp.com>")
|> reply_to("test@#sendgrid.com")
|> to("leafybasil+smtp@gmail.com")
|> cc("leafybasil+smtp@gmail.com")
|> bcc("leafybasil+smtp@gmail.com")
|> subject("SMTP integration test")
|> text_body("Hey, just testing!")
|> html_body("<h1>Hey, just <i>testing!</i></h1>")

assert {:ok, response} = Swoosh.Adapters.SMTP.deliver(email, config)
end
end
1 change: 1 addition & 0 deletions test/test_helper.exs
@@ -1,3 +1,4 @@
ExUnit.start()
ExUnit.configure(exclude: :external)

Application.ensure_all_started(:bypass)

0 comments on commit 3b808cc

Please sign in to comment.