From 8a6c6ed7559b7ef9c1a1eda94ab1c32cc99cca4e Mon Sep 17 00:00:00 2001 From: Dustin Farris Date: Wed, 8 Feb 2023 04:54:18 -0800 Subject: [PATCH] refactor: only define test repo if sqlite3 is available (#67) This keeps the compiler happy if we're in a project or environment in which the user has chosen not to opt in to sqlite3 usage. --- lib/snowflex/sqlite_test_repo.ex | 10 ++++++---- mix.exs | 2 +- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/lib/snowflex/sqlite_test_repo.ex b/lib/snowflex/sqlite_test_repo.ex index edd5874..1e1dd7d 100644 --- a/lib/snowflex/sqlite_test_repo.ex +++ b/lib/snowflex/sqlite_test_repo.ex @@ -1,5 +1,7 @@ -defmodule Snowflex.SQLiteTestRepo do - use Ecto.Repo, - otp_app: :snowflex, - adapter: Ecto.Adapters.SQLite3 +if Code.ensure_loaded?(Ecto.Adapters.SQLite3) do + defmodule Snowflex.SQLiteTestRepo do + use Ecto.Repo, + otp_app: :snowflex, + adapter: Ecto.Adapters.SQLite3 + end end diff --git a/mix.exs b/mix.exs index 805653e..ac9a2aa 100644 --- a/mix.exs +++ b/mix.exs @@ -54,7 +54,7 @@ defmodule Snowflex.MixProject do {:dialyxir, "~> 1.0", only: :dev, runtime: false}, {:ex_doc, ">= 0.0.0", only: :dev, runtime: false}, {:meck, "~> 0.9", only: :test}, - {:ecto_sqlite3, "~> 0.8.2", only: [:dev, :test]} + {:ecto_sqlite3, "~> 0.8.2", optional: true, only: [:dev, :test]} ] end