Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

move setting application config in test to setup block via the real data tag #1

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion test/test_helper.exs
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
ExUnit.configure(exclude: [real_data: true])
ExUnit.configure(exclude: [:real_data])
ExUnit.start()
12 changes: 9 additions & 3 deletions test/worldly/country_test.exs
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
defmodule Worldly.CountryTest do
use ExUnit.Case

setup context do
if context[:real_data] do
Application.put_env(:worldly, :data_path, context[:real_data])
on_exit fn -> Application.put_env(:worldly, :data_path, "priv/test_data") end
end
:ok
end

test "all/0" do
assert Worldly.Country.all == [
country_andorra,
Expand All @@ -24,11 +32,9 @@ defmodule Worldly.CountryTest do
assert Worldly.Country.with_code("ALBA") == []
end

@tag :real_data
@tag real_data: "priv/data"
test "real paths working" do
Application.put_env(:worldly, :data_path, "priv/data")
assert Worldly.Country.with_code("AL") == [country_albania]
Application.put_env(:worldly, :data_path, "priv/test_data")
end

defp country_andorra do
Expand Down