This is an automated email from the ASF dual-hosted git repository. nickva pushed a commit to branch main in repository https://gitbox.apache.org/repos/asf/couchdb.git
commit 674bd17dd8b598220827025513c85c61d03b1a93 Author: Nick Vatamaniuc <[email protected]> AuthorDate: Thu Jul 30 16:45:25 2026 -0400 Fix elixir tests After updating credo it showed a bunch of issues. FindConflicts was misnamed, some mango tests were copy pasted wrong. The test finder helper couldn't find mango tests since they are level lower and we didn't use a recursive search pattern. `pretty_print` had the wrong args order swapped when calling `map_join/3`. A few test helpers are not really tests so can just import what they need. --- mix.exs | 4 +++- test/elixir/lib/suite.ex | 4 ++-- test/elixir/test/config/suite.elixir | 4 +++- test/elixir/test/mango/19_find_conflicts_test.exs | 2 +- test/elixir/test/mango/22_covering_index_test.exs | 1 - test/elixir/test/partition_helpers.exs | 2 +- test/elixir/test/reshard_helpers.exs | 3 ++- 7 files changed, 12 insertions(+), 8 deletions(-) diff --git a/mix.exs b/mix.exs index 5ae525de1..701bef5f6 100644 --- a/mix.exs +++ b/mix.exs @@ -50,7 +50,8 @@ defmodule CouchDBTest.Mixfile do [ app: :couchdbtest, version: "0.1.0", - elixir: "~> 1.20", + # Depends on elixir available in our CI images + elixir: "~> 1.18", lockfile: Path.expand("mix.lock", __DIR__), deps_path: Path.expand("src", __DIR__), build_path: Path.expand("_build", __DIR__), @@ -60,6 +61,7 @@ defmodule CouchDBTest.Mixfile do deps: deps(), consolidate_protocols: Mix.env() not in [:test, :dev, :integration], test_paths: get_test_paths(Mix.env()), + test_ignore_filters: [~r/_helpers\.exs$/], elixirc_paths: elixirc_paths(Mix.env()), prune_code_paths: false, test_coverage: [ diff --git a/test/elixir/lib/suite.ex b/test/elixir/lib/suite.ex index 4d625ee9b..d21c25520 100644 --- a/test/elixir/lib/suite.ex +++ b/test/elixir/lib/suite.ex @@ -61,7 +61,7 @@ defmodule Couch.Test.Suite do def pretty_print(tests) do tests = Enum.join(Enum.sort(Enum.map(tests, fn {module_name, test_names} -> test_names = test_names - |> Enum.map_join(fn x -> ~s("#{x}") end, ",\n ") + |> Enum.map_join(",\n ", fn x -> ~s("#{x}") end) ~s( "#{module_name}": [\n #{test_names}\n ]) end)), ",\n") "%{\n#{tests}\n}" @@ -159,7 +159,7 @@ defmodule Couch.Test.Suite do end defp test_files(directory) do - files = Path.wildcard(Path.join(directory, "*_test.exs")) + files = Path.wildcard(Path.join(directory, "**/*_test.exs")) Enum.filter(files, &File.regular?/1) end diff --git a/test/elixir/test/config/suite.elixir b/test/elixir/test/config/suite.elixir index 21bfe3dc0..c392fe8df 100644 --- a/test/elixir/test/config/suite.elixir +++ b/test/elixir/test/config/suite.elixir @@ -845,7 +845,6 @@ "scenario no matches, indexed column" ], "ChooseCorrectIndexForDocs": [ - "retrieve conflicts", "choose index with one field in index", "choose index with two", "choose index alphabetically", @@ -857,6 +856,9 @@ "choose index with id", "choose index with rev" ], + "FindConflictsTest": [ + "retrieve conflicts" + ], "RegularCoveringIndexTest": [ "index covers query 1 field index id", "index covers query 2 field index id", diff --git a/test/elixir/test/mango/19_find_conflicts_test.exs b/test/elixir/test/mango/19_find_conflicts_test.exs index c8fdf41cd..373d64247 100644 --- a/test/elixir/test/mango/19_find_conflicts_test.exs +++ b/test/elixir/test/mango/19_find_conflicts_test.exs @@ -10,7 +10,7 @@ # License for the specific language governing permissions and limitations under # the License. -defmodule ChooseCorrectIndexForDocs do +defmodule FindConflictsTest do use CouchTestCase @db_name "find-conflicts" diff --git a/test/elixir/test/mango/22_covering_index_test.exs b/test/elixir/test/mango/22_covering_index_test.exs index eda0ded4a..8722ec827 100644 --- a/test/elixir/test/mango/22_covering_index_test.exs +++ b/test/elixir/test/mango/22_covering_index_test.exs @@ -11,7 +11,6 @@ # the License. defmodule CoveringIndexTest do - use CouchTestCase defmacro describe(db) do quote do test "index covers query 1 field index id" do diff --git a/test/elixir/test/partition_helpers.exs b/test/elixir/test/partition_helpers.exs index 3322ed7f5..332e11f3d 100644 --- a/test/elixir/test/partition_helpers.exs +++ b/test/elixir/test/partition_helpers.exs @@ -1,5 +1,5 @@ defmodule PartitionHelpers do - use ExUnit.Case + import ExUnit.Assertions def create_partition_docs(db_name, pk1 \\ "foo", pk2 \\ "bar") do docs = diff --git a/test/elixir/test/reshard_helpers.exs b/test/elixir/test/reshard_helpers.exs index 282d98c82..992d0bbbc 100644 --- a/test/elixir/test/reshard_helpers.exs +++ b/test/elixir/test/reshard_helpers.exs @@ -1,5 +1,6 @@ defmodule ReshardHelpers do - use CouchTestCase + import ExUnit.Assertions + import Couch.DBTest, only: [retry_until: 3] def get_summary do resp = Couch.get("/_reshard")
