Skip to content

Commit

Permalink
more tests
Browse files Browse the repository at this point in the history
  • Loading branch information
jarlah committed Nov 6, 2023
1 parent 993b8c5 commit 2df0a40
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 0 deletions.
4 changes: 4 additions & 0 deletions lib/ecto.ex
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,10 @@ defmodule Testcontainers.Ecto do
repo
end

if not :erlang.function_exported(repo, :__info__, 1) do
raise ArgumentError, "Repo is invalid: repo=#{inspect(repo)}"
end

user = Keyword.get(options, :user, "test")
password = Keyword.get(options, :password, "test")
database = Keyword.get(options, :database, "#{Atom.to_string(app)}_test")
Expand Down
31 changes: 31 additions & 0 deletions test/ecto_errors_test.exs
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
defmodule Testcontainers.EctoMysqlTest do

Check warning on line 1 in test/ecto_errors_test.exs

View workflow job for this annotation

GitHub Actions / Build and test

redefining module Testcontainers.EctoMysqlTest (current version defined in memory)
use ExUnit.Case, async: true

import Testcontainers.Ecto

test "repo cannot be nil" do
assert_raise ArgumentError, "Repo is invalid: repo=Testcontainers.Repo", fn ->
mysql_container(
app: :testcontainers,
repo: nil
)
end
end

test "repo must be atom" do
assert_raise ArgumentError, "Not an atom: repo=\"hello\"", fn ->
mysql_container(
app: :testcontainers,
repo: "hello"
)
end
end

test "app must be atom" do
assert_raise ArgumentError, "Missing or not an atom: app=\"hello\"", fn ->
mysql_container(
app: "hello"
)
end
end
end

0 comments on commit 2df0a40

Please sign in to comment.