From 24fca7b4b967703d2ca303a0c7e2f6f404209a86 Mon Sep 17 00:00:00 2001 From: Nik Sidnev Date: Fri, 29 Nov 2024 16:25:10 -0500 Subject: [PATCH] add support for `GEL_` options --- .github/workflows/docs.yml | 2 +- .github/workflows/release.yml | 2 +- .github/workflows/styles.yml | 2 +- .github/workflows/tests.yml | 4 + CHANGELOG.md | 5 + gel.toml | 5 + lib/edgedb/connection/config.ex | 275 +++++++++++++--------- lib/edgedb/connection/config/dsn.ex | 28 +-- mix.exs | 2 +- test/shared/connection_test.exs | 40 ++-- test/shared/project_path_hashing_test.exs | 4 +- test/support/shared-client-testcases | 2 +- test/support/shared_case.ex | 31 ++- 13 files changed, 238 insertions(+), 164 deletions(-) create mode 100644 gel.toml diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml index 61529a8e..9613c514 100644 --- a/.github/workflows/docs.yml +++ b/.github/workflows/docs.yml @@ -26,7 +26,7 @@ jobs: - uses: erlef/setup-beam@v1 with: otp-version: "26.0" - elixir-version: "1.16" + elixir-version: "1.17" - uses: r-lib/actions/setup-pandoc@v2 with: diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index c2a2c4db..dbb54e63 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -20,7 +20,7 @@ jobs: - uses: erlef/setup-beam@v1 with: otp-version: "26.0" - elixir-version: "1.16" + elixir-version: "1.17" - name: Install dependencies run: mix deps.get diff --git a/.github/workflows/styles.yml b/.github/workflows/styles.yml index 80edf5f8..2d54ba1a 100644 --- a/.github/workflows/styles.yml +++ b/.github/workflows/styles.yml @@ -26,7 +26,7 @@ jobs: - uses: erlef/setup-beam@v1 with: otp-version: "26.0" - elixir-version: "1.16" + elixir-version: "1.17" - name: Set up cache uses: actions/cache@v4.1.2 diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 4851db7b..6f58d3b5 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -28,6 +28,7 @@ jobs: - "1.14" - "1.15" - "1.16" + - "1.17" edgedb-version: - "2.0" @@ -51,6 +52,9 @@ jobs: - elixir-version: "1.16" otp-version: "24.3" + - elixir-version: "1.17" + otp-version: "24.3" + runs-on: ${{ matrix.os-version }} steps: diff --git a/CHANGELOG.md b/CHANGELOG.md index f0d4e924..940d42bb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 [Compare with 0.7.0](https://github.com/edgedb/edgedb-elixir/compare/v0.7.0...HEAD) +### Added + +- support for Gel connection options. +- support for `Elixir v1.17`. + ## [0.7.0] - 2024-05-05 [Compare with 0.6.1](https://github.com/edgedb/edgedb-elixir/compare/v0.6.1...v0.7.0) diff --git a/gel.toml b/gel.toml new file mode 100644 index 00000000..ef4c8052 --- /dev/null +++ b/gel.toml @@ -0,0 +1,5 @@ +[edgedb] +server-version = "5.2" + +[project] +schema-dir = "./priv/edgedb/schema" diff --git a/lib/edgedb/connection/config.ex b/lib/edgedb/connection/config.ex index 773b4eca..4f3dc643 100644 --- a/lib/edgedb/connection/config.ex +++ b/lib/edgedb/connection/config.ex @@ -8,6 +8,8 @@ defmodule EdgeDB.Connection.Config do Validation } + require Logger + @default_host "localhost" @default_port 5656 @default_database "edgedb" @@ -17,7 +19,7 @@ defmodule EdgeDB.Connection.Config do @dsn_regex ~r"^[a-z]+://" @instance_name_regex ~r/^(\w(?:-?\w)*)$/ - @cloud_instance_name_regex ~r|^([A-Za-z0-9](?:-?[A-Za-z0-9])*)/([A-Za-z0-9](?:-?[A-Za-z0-9])*)$| + @cloud_instance_name_regex ~r|^([A-Za-z0-9_-](?:-?[A-Za-z0-9_])*)/([A-Za-z0-9](?:-?[A-Za-z0-9])*)$| @file_module Application.compile_env(:edgedb, :file_module, File) @path_module Application.compile_env(:edgedb, :path_module, Path) @@ -113,7 +115,7 @@ defmodule EdgeDB.Connection.Config do end defp resolve_explicit_opts(opts) do - case resolve_opts([], opts) do + case resolve_opts([], [], opts) do {resolved_opts, 0} -> {:cont, resolved_opts} @@ -129,7 +131,7 @@ defmodule EdgeDB.Connection.Config do end defp resolve_config_opts(resolved_opts) do - case resolve_opts(resolved_opts, config_opts()) do + case resolve_opts(resolved_opts, [], config_opts(:edgedb)) do {resolved_opts, 0} -> {:cont, resolved_opts} @@ -145,7 +147,7 @@ defmodule EdgeDB.Connection.Config do end defp resolve_environment_opts(resolved_opts) do - case resolve_opts(resolved_opts, environment_opts()) do + case resolve_opts(resolved_opts, environment_opts("GEL"), environment_opts("EDGEDB")) do {resolved_opts, 0} -> {:cont, resolved_opts} @@ -155,19 +157,20 @@ defmodule EdgeDB.Connection.Config do _other -> raise EdgeDB.ClientConnectionError.new( "can not have more than one of the following connection environment variables:" <> - ~s("EDGEDB_DSN", "EDGEDB_INSTANCE", ) <> - ~s("EDGEDB_CREDENTIALS_FILE" or "EDGEDB_HOST"/"EDGEDB_PORT") + ~s("GEL_DSN"/"EDGEDB_DSN", "GEL_INSTANCE"/"EDGEDB_INSTANCE", ) <> + ~s("GEL_CREDENTIALS_FILE"/"EDGEDB_CREDENTIALS_FILE" or ) <> + ~s("GEL_HOST"/"GEL_PORT"/"EDGEDB_HOST"/"EDGEDB_PORT") ) end end defp resolve_project_opts(resolved_opts) do - project_dir = find_edgedb_project_dir() + {project, project_dir} = find_project_dir() stash_dir = Credentials.stash_dir(project_dir) if not @file_module.exists?(stash_dir) do raise EdgeDB.ClientConnectionError.new( - ~s(found "edgedb.toml" but the project is not initialized, run "edgedb project init") + ~s(found "#{project}.toml" but the project is not initialized, run "#{project} project init") ) end @@ -218,90 +221,119 @@ defmodule EdgeDB.Connection.Config do project_opts end - {resolved_opts, _compounds} = resolve_opts(resolved_opts, project_opts) + {resolved_opts, _compounds} = resolve_opts(resolved_opts, [], project_opts) resolved_opts end - defp resolve_opts(resolved_opts, opts) do + defp resolve_opts(resolved_opts, gel_opts, edgedb_opts) do resolved_opts = resolved_opts |> Keyword.put_new_lazy(:user, fn -> - Validation.validate_user(opts[:user]) + :user + |> fetch_option(gel_opts, edgedb_opts) + |> Validation.validate_user() end) - |> Keyword.put_new(:password, opts[:password]) + |> Keyword.put_new(:password, fetch_option(:password, gel_opts, edgedb_opts)) |> Keyword.put_new_lazy(:tls_ca_file, fn -> - Validation.validate_tls_ca_file(opts[:tls_ca_file]) + :tls_ca_file + |> fetch_option(gel_opts, edgedb_opts) + |> Validation.validate_tls_ca_file() end) |> Keyword.put_new_lazy(:tls_security, fn -> - Validation.validate_tls_security(opts[:tls_security]) + :tls_security + |> fetch_option(gel_opts, edgedb_opts) + |> Validation.validate_tls_security() end) |> Keyword.put_new_lazy(:tls_server_name, fn -> - Validation.validate_tls_server_name(opts[:tls_server_name]) + :tls_server_name + |> fetch_option(gel_opts, edgedb_opts) + |> Validation.validate_tls_server_name() end) |> Keyword.put_new_lazy(:server_settings, fn -> - Validation.validate_server_settings(opts[:server_settings]) + :server_settings + |> fetch_option(gel_opts, edgedb_opts) + |> Validation.validate_server_settings() end) |> Enum.reject(fn {_key, value} -> is_nil(value) end) - if not is_nil(opts[:database]) and not is_nil(opts[:branch]) do + database = fetch_option(:database, gel_opts, edgedb_opts) + branch = fetch_option(:branch, gel_opts, edgedb_opts) + + if not is_nil(database) and not is_nil(branch) do raise EdgeDB.ClientConnectionError.new(":database and :branch keys are mutually exclusive") end resolved_opts = - if not is_nil(opts[:database]) and is_nil(resolved_opts[:branch]) do + if not is_nil(database) and is_nil(resolved_opts[:branch]) do Keyword.put_new_lazy(resolved_opts, :database, fn -> - Validation.validate_database(opts[:database]) + Validation.validate_database(database) end) else resolved_opts end resolved_opts = - if not is_nil(opts[:branch]) and is_nil(resolved_opts[:database]) do + if not is_nil(branch) and is_nil(resolved_opts[:database]) do Keyword.put_new_lazy(resolved_opts, :branch, fn -> - Validation.validate_database(opts[:branch]) + Validation.validate_database(branch) end) else resolved_opts end - opts = Keyword.drop(opts, [:database, :branch]) + gel_opts = Keyword.drop(gel_opts, [:database, :branch]) + edgedb_opts = Keyword.drop(edgedb_opts, [:database, :branch]) + + dsn = fetch_option(:dsn, gel_opts, edgedb_opts) + instance_name = fetch_option(:instance_name, gel_opts, edgedb_opts) + credentials = fetch_option(:credentials, gel_opts, edgedb_opts) + credentials_file = fetch_option(:credentials_file, gel_opts, edgedb_opts) + host = fetch_option(:host, gel_opts, edgedb_opts) + port = fetch_option(:port, gel_opts, edgedb_opts) compound_params_count = [ - opts[:dsn], - opts[:instance_name], - opts[:credentials], - opts[:credentials_file], - opts[:host] || opts[:port] + dsn, + instance_name, + credentials, + credentials_file, + host || port ] |> Enum.reject(&is_nil/1) |> Enum.count() resolved_opts = cond do - compound_params_count == 1 and not is_nil(opts[:dsn] || opts[:host] || opts[:port]) -> + compound_params_count == 1 and not is_nil(dsn || host || port) -> resolved_opts = - if port = opts[:port] do + if port do Keyword.put_new(resolved_opts, :port, Validation.validate_port(port)) else resolved_opts end dsn = - if dsn = opts[:dsn] do + if dsn do dsn else - "gel://#{parse_host(opts[:host])}" + "gel://#{parse_host(host)}" end DSN.parse_dsn_into_opts(dsn, resolved_opts) compound_params_count == 1 -> - credentials = parse_credentials(opts, resolved_opts) + credentials_opts = [ + credentials_file: credentials_file, + credentials: credentials, + instance_name: instance_name, + secret_key: fetch_option(:secret_key, gel_opts, edgedb_opts), + cloud_profile: fetch_option(:cloud_profile, gel_opts, edgedb_opts) + ] + + credentials = parse_credentials(credentials_opts, resolved_opts) safe_credentials = Keyword.drop(credentials, [:database, :branch]) resolved_opts = Keyword.merge(safe_credentials, resolved_opts) @@ -330,10 +362,35 @@ defmodule EdgeDB.Connection.Config do resolved_opts end - resolved_opts = Keyword.merge(opts, resolved_opts) + resolved_opts = + edgedb_opts + |> Keyword.merge(gel_opts) + |> Keyword.merge(resolved_opts) + {resolved_opts, compound_params_count} end + defp fetch_option(option, gel_opts, edgedb_opts) do + case {gel_opts[option], edgedb_opts[option]} do + {nil, nil} -> + nil + + {gel_value, nil} -> + gel_value + + {nil, edgedb_value} -> + edgedb_value + + {gel_value, _edgedb_value} -> + Logger.warning( + "#{option} key is set for Gel and EdgeDB configurations at the same time, " <> + "value from EdgeDB configuration will be ignored" + ) + + gel_value + end + end + defp parse_credentials(opts, resolved_opts) do cond do credentials_file = opts[:credentials_file] -> @@ -353,7 +410,8 @@ defmodule EdgeDB.Connection.Config do cloud_profile = opts[:cloud_profile] || resolved_opts[:cloud_profile] || - from_env("EDGEDB_CLOUD_PROFILE") + from_env("GEL", "CLOUD_PROFILE") || + from_env("EDGEDB", "CLOUD_PROFILE") Cloud.parse_cloud_credentials(org_slug, instance_name, secret_key, cloud_profile) @@ -365,41 +423,41 @@ defmodule EdgeDB.Connection.Config do end end - defp config_opts do + defp config_opts(app) do clear_opts( - dsn: from_config(:dsn), - instance_name: from_config(:instance_name), - credentials: from_config(:credentials), - credentials_file: from_config(:credentials_file), - host: from_config(:host), - port: from_config(:port), - database: from_config(:database), - branch: from_config(:branch), - user: from_config(:user), - password: from_config(:password), - secret_key: from_config(:secret_key), - cloud_profile: from_config(:cloud_profile), - tls_ca: from_config(:tls_ca), - tls_ca_file: from_config(:tls_ca_file), - tls_security: from_config(:tls_security), - tls_server_name: from_config(:tls_server_name), - timeout: from_config(:timeout), - command_timeout: from_config(:command_timeout), - wait_for_available: from_config(:wait_for_available), - server_settings: from_config(:server_settings), - tcp: from_config(:tcp), - ssl: from_config(:ssl), - transaction: from_config(:transaction), - retry: from_config(:retry), - connection: from_config(:connection), - pool: from_config(:pool), - client_state: from_config(:client_state) + dsn: from_config(app, :dsn), + instance_name: from_config(app, :instance_name), + credentials: from_config(app, :credentials), + credentials_file: from_config(app, :credentials_file), + host: from_config(app, :host), + port: from_config(app, :port), + database: from_config(app, :database), + branch: from_config(app, :branch), + user: from_config(app, :user), + password: from_config(app, :password), + secret_key: from_config(app, :secret_key), + cloud_profile: from_config(app, :cloud_profile), + tls_ca: from_config(app, :tls_ca), + tls_ca_file: from_config(app, :tls_ca_file), + tls_security: from_config(app, :tls_security), + tls_server_name: from_config(app, :tls_server_name), + timeout: from_config(app, :timeout), + command_timeout: from_config(app, :command_timeout), + wait_for_available: from_config(app, :wait_for_available), + server_settings: from_config(app, :server_settings), + tcp: from_config(app, :tcp), + ssl: from_config(app, :ssl), + transaction: from_config(app, :transaction), + retry: from_config(app, :retry), + connection: from_config(app, :connection), + pool: from_config(app, :pool), + client_state: from_config(app, :client_state) ) end - defp environment_opts do + defp environment_opts(prefix) do port = - case from_env("EDGEDB_PORT") do + case from_env(prefix, "PORT") do "tcp" <> _term -> nil @@ -408,26 +466,26 @@ defmodule EdgeDB.Connection.Config do end security = - "EDGEDB_CLIENT_SECURITY" - |> from_env() + prefix + |> from_env("CLIENT_SECURITY") |> Validation.validate_security() clear_opts( - dsn: from_env("EDGEDB_DSN"), - instance_name: from_env("EDGEDB_INSTANCE"), - credentials_file: from_env("EDGEDB_CREDENTIALS_FILE"), - host: from_env("EDGEDB_HOST"), + dsn: from_env(prefix, "DSN"), + instance_name: from_env(prefix, "INSTANCE"), + credentials_file: from_env(prefix, "CREDENTIALS_FILE"), + host: from_env(prefix, "HOST"), port: port, - database: from_env("EDGEDB_DATABASE"), - branch: from_env("EDGEDB_BRANCH"), - user: from_env("EDGEDB_USER"), - password: from_env("EDGEDB_PASSWORD"), - secret_key: from_env("EDGEDB_SECRET_KEY"), - cloud_profile: from_env("EDGEDB_CLOUD_PROFILE"), - tls_ca: from_env("EDGEDB_TLS_CA"), - tls_ca_file: from_env("EDGEDB_TLS_CA_FILE"), - tls_security: from_env("EDGEDB_CLIENT_TLS_SECURITY"), - tls_server_name: from_env("EDGEDB_TLS_SERVER_NAME"), + database: from_env(prefix, "DATABASE"), + branch: from_env(prefix, "BRANCH"), + user: from_env(prefix, "USER"), + password: from_env(prefix, "PASSWORD"), + secret_key: from_env(prefix, "SECRET_KEY"), + cloud_profile: from_env(prefix, "CLOUD_PROFILE"), + tls_ca: from_env(prefix, "TLS_CA"), + tls_ca_file: from_env(prefix, "TLS_CA_FILE"), + tls_security: from_env(prefix, "CLIENT_TLS_SECURITY"), + tls_server_name: from_env(prefix, "TLS_SERVER_NAME"), security: security ) end @@ -442,44 +500,51 @@ defmodule EdgeDB.Connection.Config do end) end - defp from_config(name) do - Application.get_env(:edgedb, name) + defp from_config(app, name) do + Application.get_env(app, name) end - defp from_env(name) do - @system_module.get_env(name) + defp from_env(prefix, name) do + @system_module.get_env("#{prefix}_#{name}") end - defp find_edgedb_project_dir do + defp find_project_dir do dir = @file_module.cwd!() - find_edgedb_project_dir(dir) + find_project_dir(dir) end - defp find_edgedb_project_dir(dir) do + defp find_project_dir(dir) do dev = @file_module.stat!(dir).major_device - project_file = @path_module.join(dir, "edgedb.toml") - if @file_module.exists?(project_file) do - dir - else - parent = @path_module.dirname(dir) + gel_project_file = @path_module.join(dir, "gel.toml") + edgedb_project_file = @path_module.join(dir, "edgedb.toml") - if parent == dir do - raise EdgeDB.ClientConnectionError.new( - ~s(no "edgedb.toml" found and no connection options specified) - ) - end + cond do + @file_module.exists?(gel_project_file) -> + {"gel", dir} - parent_dev = @file_module.stat!(parent).major_device + @file_module.exists?(edgedb_project_file) -> + {"edgedb", dir} - if parent_dev != dev do - raise EdgeDB.ClientConnectionError.new( - ~s(no "edgedb.toml" found and no connection options specified) <> - ~s(stopped searching for "edgedb.toml" at file system boundary #{inspect(dir)}) - ) - end + true -> + parent = @path_module.dirname(dir) + + if parent == dir do + raise EdgeDB.ClientConnectionError.new( + ~s(no "gel.toml" or "edgedb.toml" found and no connection options specified) + ) + end + + parent_dev = @file_module.stat!(parent).major_device + + if parent_dev != dev do + raise EdgeDB.ClientConnectionError.new( + ~s(no "gel.toml" or "edgedb.toml" found and no connection options specified) <> + ~s(stopped searching for "gel.toml"/"edgedb.toml" at file system boundary #{inspect(dir)}) + ) + end - find_edgedb_project_dir(parent) + find_project_dir(parent) end end diff --git a/lib/edgedb/connection/config/dsn.ex b/lib/edgedb/connection/config/dsn.ex index e3fbbafa..a17aff58 100644 --- a/lib/edgedb/connection/config/dsn.ex +++ b/lib/edgedb/connection/config/dsn.ex @@ -33,37 +33,21 @@ defmodule EdgeDB.Connection.Config.DSN do parse(%URI{dsn | path: nil}, opts) end - defp parse( - %URI{ - scheme: "edgedb" - } = dsn, - opts - ) do - parse_inner(dsn, opts) + defp parse(%URI{scheme: "gel"} = dsn, opts) do + parse_dsn(dsn, opts) end - defp parse( - %URI{ - scheme: "gel" - } = dsn, - opts - ) do - parse_inner(dsn, opts) + defp parse(%URI{scheme: "edgedb"} = dsn, opts) do + parse_dsn(dsn, opts) end defp parse(%URI{} = dsn, _opts) do raise RuntimeError, message: - ~s(invalid DSN or instance name: scheme is expected to be "gel", got #{inspect(dsn.scheme)}) + ~s(invalid DSN or instance name: scheme is expected to be "gel" or "edgedb", got #{inspect(dsn.scheme)}) end - defp parse_inner( - %URI{ - path: uri_database, - query: query - } = dsn, - opts - ) do + defp parse_dsn(%URI{path: uri_database, query: query} = dsn, opts) do %URI{host: host, port: port} = maybe_handle_ipv6_zone(dsn) {user, password} = diff --git a/mix.exs b/mix.exs index 55177a5b..5b131fc5 100644 --- a/mix.exs +++ b/mix.exs @@ -2,7 +2,7 @@ defmodule EdgeDB.MixProject do use Mix.Project @app :edgedb - @version "0.7.0" + @version "0.7.1" @source_url "https://github.com/edgedb/edgedb-elixir" @description "EdgeDB client for Elixir" diff --git a/test/shared/connection_test.exs b/test/shared/connection_test.exs index 9af69e9a..d6bcf2d0 100644 --- a/test/shared/connection_test.exs +++ b/test/shared/connection_test.exs @@ -20,12 +20,12 @@ if File.exists?(testcases_file) do {EdgeDB.Error, type: EdgeDB.ClientConnectionError, name: "ClientConnectionError", - message: ~r/found "edgedb.toml" but the project is not initialized/}, + message: ~r/found "(gel|edgedb).toml" but the project is not initialized/}, "no_options_or_toml" => {EdgeDB.Error, type: EdgeDB.ClientConnectionError, name: "ClientConnectionError", - message: ~r/no "edgedb.toml" found and no connection options specified/}, + message: ~r/no "gel.toml" or "edgedb.toml" found and no connection options specified/}, "invalid_credentials_file" => {RuntimeError, message: ~r/invalid credentials/}, "invalid_dsn_or_instance_name" => {RuntimeError, message: ~r/invalid DSN or instance name/}, "invalid_instance_name" => {RuntimeError, message: ~r/invalid instance name/}, @@ -73,30 +73,30 @@ if File.exists?(testcases_file) do } @known_case_errors Map.keys(@case_to_client_errors) - for {testcase, index} <- Enum.with_index(@cases, 1) do - @tag String.to_atom("shared_connection_testcase_#{index}") + for testcase <- @cases do + describe "shared testcase for connection options parsing: #{testcase["name"]}" do + @tag String.to_atom("shared_connection_testcase_#{testcase["name"]}") - with %{"fs" => fs_mapping} when map_size(fs_mapping) != 0 <- testcase do - platform = testcase["platform"] + @tag testcase: testcase + @tag debug: @debug_shared - cond do - platform == "windows" or :os.type() == {:nt, :win32} -> - @tag :skip + with %{"fs" => fs_mapping} when map_size(fs_mapping) != 0 <- testcase do + platform = testcase["platform"] - platform == "macos" and :os.type() != {:unix, :darwin} -> - @tag :skip + cond do + platform == "windows" or :os.type() == {:nt, :win32} -> + @tag :skip - is_nil(platform) and :os.type() == {:unix, :darwin} -> - @tag :skip + platform == "macos" and :os.type() != {:unix, :darwin} -> + @tag :skip - true -> - :ok - end - end + is_nil(platform) and :os.type() == {:unix, :darwin} -> + @tag :skip - describe "shared testcase for connection options parsing ##{index}" do - @tag testcase: testcase - @tag debug: @debug_shared + true -> + :ok + end + end setup [ :setup_debug, diff --git a/test/shared/project_path_hashing_test.exs b/test/shared/project_path_hashing_test.exs index cb8e2c0d..9af89a75 100644 --- a/test/shared/project_path_hashing_test.exs +++ b/test/shared/project_path_hashing_test.exs @@ -10,9 +10,9 @@ if File.exists?(testcases_file) do @moduletag :project_path_hashing for {testcase, index} <- Enum.with_index(@cases, 1) do - @tag String.to_atom("shared_project_path_hasing_testcase_#{index}") - describe "shared testcase for project path hashing ##{index}" do + @tag String.to_atom("shared_project_path_hasing_testcase_#{index}") + @tag testcase: testcase @tag debug: @debug_shared diff --git a/test/support/shared-client-testcases b/test/support/shared-client-testcases index 94099c29..e395996f 160000 --- a/test/support/shared-client-testcases +++ b/test/support/shared-client-testcases @@ -1 +1 @@ -Subproject commit 94099c29e0811b0fb1f662b5089fbeaaaa3d4e9f +Subproject commit e395996f14b6a2bfed7f8e08676a73414895c93d diff --git a/test/support/shared_case.ex b/test/support/shared_case.ex index dab7fca3..648543e0 100644 --- a/test/support/shared_case.ex +++ b/test/support/shared_case.ex @@ -16,7 +16,8 @@ defmodule Tests.Support.SharedCase do import unquote(__MODULE__) - @debug_shared System.get_env("EDGEDB_SHARED_TESTS_DEBUG", "") != "" + @debug_shared System.get_env("EDGEDB_SHARED_TESTS_DEBUG", "") != "" || + System.get_env("GEL_SHARED_TESTS_DEBUG", "") != "" @moduletag :shared @moduletag capture_log: !@debug_shared @@ -166,21 +167,31 @@ defmodule Tests.Support.SharedCase do end def setup_fs(_context) do - Logger.debug("configure files so that `edgedb.toml` won't exist") + Logger.debug("configure files so that `gel.toml` and `edgedb.toml` won't exist") stub(Mocks.FileMock, :exists?, fn path -> - if path == Path.join(File.cwd!(), "edgedb.toml") do - false - else - File.exists?(path) + cond do + path == Path.join(File.cwd!(), "gel.toml") -> + false + + path == Path.join(File.cwd!(), "edgedb.toml") -> + false + + true -> + File.exists?(path) end end) stub(Mocks.FileMock, :exists?, fn path, _opts -> - if path == Path.join(File.cwd!(), "edgedb.toml") do - false - else - File.exists?(path) + cond do + path == Path.join(File.cwd!(), "gel.toml") -> + false + + path == Path.join(File.cwd!(), "edgedb.toml") -> + false + + true -> + File.exists?(path) end end)