From fdf0dc23da01571bcbdf1aa08c07d83941976c66 Mon Sep 17 00:00:00 2001 From: Mitchell Henke Date: Wed, 15 Mar 2017 11:35:29 -0500 Subject: [PATCH] fix test warnings --- mix.exs | 3 +++ test/support/repo.ex | 22 ++++++++++++++++++++++ test/test_helper.exs | 23 ----------------------- 3 files changed, 25 insertions(+), 23 deletions(-) create mode 100644 test/support/repo.ex diff --git a/mix.exs b/mix.exs index 16aaaa7a..41466808 100644 --- a/mix.exs +++ b/mix.exs @@ -9,6 +9,7 @@ defmodule PaperTrail.Mixfile do description: description(), build_embedded: Mix.env == :prod, start_permanent: Mix.env == :prod, + elixirc_paths: elixirc_paths(Mix.env), package: package(), deps: deps() ] @@ -50,4 +51,6 @@ defmodule PaperTrail.Mixfile do } ] end + defp elixirc_paths(:test), do: ["lib", "test/support"] + defp elixirc_paths(_), do: ["lib"] end diff --git a/test/support/repo.ex b/test/support/repo.ex new file mode 100644 index 00000000..ca0ded51 --- /dev/null +++ b/test/support/repo.ex @@ -0,0 +1,22 @@ +defmodule PaperTrail.Repo do + use Ecto.Repo, otp_app: :paper_trail +end + +defmodule User do + use Ecto.Schema + + import Ecto.Changeset + + schema "users" do + field :token, :string + field :username, :string + + timestamps() + end + + def changeset(model, params \\ %{}) do + model + |> cast(params, [:token, :username]) + |> validate_required([:token, :username]) + end +end diff --git a/test/test_helper.exs b/test/test_helper.exs index f224b87f..0fec7e47 100644 --- a/test/test_helper.exs +++ b/test/test_helper.exs @@ -1,28 +1,5 @@ # TODO: strict_mode(check the current_version_id changes on next versions), Test error cases, producer_id, PaperTrail.insert_all -defmodule PaperTrail.Repo do - use Ecto.Repo, otp_app: :paper_trail -end - -defmodule User do - use Ecto.Schema - - import Ecto.Changeset - - schema "users" do - field :token, :string - field :username, :string - - timestamps() - end - - def changeset(model, params \\ %{}) do - model - |> cast(params, [:token, :username]) - |> validate_required([:token, :username]) - end -end - Mix.Task.run "ecto.create", ~w(-r PaperTrail.Repo) Mix.Task.run "ecto.migrate", ~w(-r PaperTrail.Repo)