diff --git a/lib/xandra/cluster.ex b/lib/xandra/cluster.ex index 6aabdb8d..c66f00db 100644 --- a/lib/xandra/cluster.ex +++ b/lib/xandra/cluster.ex @@ -329,6 +329,7 @@ defmodule Xandra.Cluster do def start_link(options) when is_list(options) do {cluster_opts, connection_opts} = Keyword.split(options, @start_link_opts_schema_keys) cluster_opts = NimbleOptions.validate!(cluster_opts, @start_link_opts_schema) + connection_opts = NimbleOptions.validate!(connection_opts, Xandra.start_link_opts_schema()) Pool.start_link(cluster_opts, connection_opts) end diff --git a/test/xandra/cluster_test.exs b/test/xandra/cluster_test.exs index ea90b221..47463ed4 100644 --- a/test/xandra/cluster_test.exs +++ b/test/xandra/cluster_test.exs @@ -141,6 +141,12 @@ defmodule Xandra.ClusterTest do Xandra.Cluster.start_link(nodes: ["example.com:9042"], name: "something something") end end + + test "raises with an option that is not valid for the cluster and for the conn" do + assert_raise NimbleOptions.ValidationError, ~r"unknown options \[:port\]", fn -> + Xandra.Cluster.start_link(port: 9042) + end + end end describe "start_link/1" do diff --git a/test/xandra_test.exs b/test/xandra_test.exs index d22fc9be..7d9a788c 100644 --- a/test/xandra_test.exs +++ b/test/xandra_test.exs @@ -234,12 +234,12 @@ defmodule XandraTest do end) |> Enum.map(fn {:ok, result} -> result end) - # The first and second calls succeeds, but the third call fails because it goes over + # The first call succeeds, but the second call fails because it goes over # the max concurrent conns. assert [ {1, {:ok, %Xandra.Page{}}}, {2, {:error, %ConnectionError{reason: :too_many_concurrent_requests} = error}} - ] = results + ] = Enum.sort_by(results, &elem(&1, 0)) assert Exception.message(error) =~ "this connection has too many requests in flight" end