From 46c1ce4165fbac9790f460f42aa59e6872b13322 Mon Sep 17 00:00:00 2001 From: Russell Matney Date: Sun, 12 Feb 2017 01:40:42 -0500 Subject: [PATCH 1/2] chore(ex:1.4): update per elixir 1.4 warning deprecations --- lib/rethinkdb/connection.ex | 43 +++++++------ lib/rethinkdb/connection/request.ex | 4 +- lib/rethinkdb/prepare.ex | 8 +-- lib/rethinkdb/query.ex | 2 +- mix.exs | 4 +- test/changes_test.exs | 10 +-- test/connection_test.exs | 18 +++--- test/prepare_test.exs | 8 +-- test/query/administration_query_test.exs | 4 +- test/query/aggregation_test.exs | 2 +- test/query/control_structures_adv_test.exs | 4 +- test/query/control_structures_test.exs | 8 +-- test/query/database_test.exs | 6 +- test/query/date_time_test.exs | 4 +- test/query/document_manipulation_test.exs | 2 +- test/query/geospatial_adv_test.exs | 4 +- test/query/geospatial_test.exs | 2 +- test/query/joins_test.exs | 4 +- test/query/math_logic_test.exs | 74 +++++++++++----------- test/query/selection_test.exs | 6 +- test/query/string_manipulation_test.exs | 4 +- test/query/table_db_test.exs | 4 +- test/query/table_index_test.exs | 4 +- test/query/table_test.exs | 8 +-- test/query/transformation_test.exs | 2 +- test/query/writing_data_test.exs | 12 ++-- test/query_test.exs | 4 +- 27 files changed, 128 insertions(+), 127 deletions(-) diff --git a/lib/rethinkdb/connection.ex b/lib/rethinkdb/connection.ex index 5979e77..e4ead17 100644 --- a/lib/rethinkdb/connection.ex +++ b/lib/rethinkdb/connection.ex @@ -51,14 +51,14 @@ defmodule RethinkDB.Connection do defmacro __using__(_opts) do quote location: :keep do def start_link(opts \\ []) do - if Dict.has_key?(opts, :name) && opts[:name] != __MODULE__ do + if Keyword.has_key?(opts, :name) && opts[:name] != __MODULE__ do # The whole point of this macro is to provide an implicit process # name, so subverting it is considered an error. raise ArgumentError.exception( "Process name #{inspect opts[:name]} conflicts with implicit name #{inspect __MODULE__} provided by `use RethinkDB.Connection`" ) end - RethinkDB.Connection.start_link(Dict.put_new(opts, :name, __MODULE__)) + RethinkDB.Connection.start_link(Keyword.put_new(opts, :name, __MODULE__)) end def run(query, opts \\ []) do @@ -98,12 +98,13 @@ defmodule RethinkDB.Connection do * `profile` - whether or not to return a profile of the query’s execution (default: false). """ def run(query, conn, opts \\ []) do - timeout = Dict.get(opts, :timeout, 5000) - conn_opts = Dict.drop(opts, [:timeout]) - noreply = Dict.get(opts, :noreply, false) + timeout = Keyword.get(opts, :timeout, 5000) + conn_opts = Keyword.drop(opts, [:timeout]) + noreply = Keyword.get(opts, :noreply, false) conn_opts = Connection.call(conn, :conn_opts) - |> Dict.take([:db]) - |> Dict.merge(conn_opts) + |> Map.to_list() + |> Keyword.take([:db]) + |> Keyword.merge(conn_opts) query = prepare_and_encode(query, conn_opts) msg = case noreply do true -> {:query_noreply, query} @@ -170,7 +171,7 @@ defmodule RethinkDB.Connection do @doc """ Start connection as a linked process - Accepts a `Dict` of options. Supported options: + Accepts a `Keyword.t` of options. Supported options: * `:host` - hostname to use to connect to database. Defaults to `'localhost'`. * `:port` - port on which to connect to database. Defaults to `28015`. @@ -182,26 +183,26 @@ defmodule RethinkDB.Connection do * `:ca_certs` - a list of file paths to cacerts. """ def start_link(opts \\ []) do - args = Dict.take(opts, [:host, :port, :auth_key, :db, :sync_connect, :ssl, :max_pending]) + args = Keyword.take(opts, [:host, :port, :auth_key, :db, :sync_connect, :ssl, :max_pending]) Connection.start_link(__MODULE__, args, opts) end def init(opts) do - host = case Dict.get(opts, :host, 'localhost') do + host = case Keyword.get(opts, :host, 'localhost') do x when is_binary(x) -> String.to_char_list x x -> x end - sync_connect = Dict.get(opts, :sync_connect, false) - ssl = Dict.get(opts, :ssl) - opts = Dict.put(opts, :host, host) - |> Dict.put_new(:port, 28015) - |> Dict.put_new(:auth_key, "") - |> Dict.put_new(:max_pending, 10000) - |> Dict.drop([:sync_connect]) + sync_connect = Keyword.get(opts, :sync_connect, false) + ssl = Keyword.get(opts, :ssl) + opts = Keyword.put(opts, :host, host) + |> Keyword.put_new(:port, 28015) + |> Keyword.put_new(:auth_key, "") + |> Keyword.put_new(:max_pending, 10000) + |> Keyword.drop([:sync_connect]) |> Enum.into(%{}) {transport, transport_opts} = case ssl do nil -> {%Transport.TCP{}, []} - x -> {%Transport.SSL{}, Enum.map(Dict.fetch!(x, :ca_certs), &({:cacertfile, &1})) ++ [verify: :verify_peer]} + x -> {%Transport.SSL{}, Enum.map(Keyword.fetch!(x, :ca_certs), &({:cacertfile, &1})) ++ [verify: :verify_peer]} end state = %{ pending: %{}, @@ -228,11 +229,11 @@ defmodule RethinkDB.Connection do :ok -> :ok = Transport.setopts(socket, [active: :once]) # TODO: investigate timeout vs hibernate - {:ok, Dict.put(state, :socket, socket)} + {:ok, Map.put(state, :socket, socket)} end {:error, :econnrefused} -> - backoff = min(Dict.get(state, :timeout, 1000), 64000) - {:backoff, backoff, Dict.put(state, :timeout, backoff*2)} + backoff = min(Map.get(state, :timeout, 1000), 64000) + {:backoff, backoff, Map.put(state, :timeout, backoff*2)} end end diff --git a/lib/rethinkdb/connection/request.ex b/lib/rethinkdb/connection/request.ex index b828dd6..88bc092 100644 --- a/lib/rethinkdb/connection/request.ex +++ b/lib/rethinkdb/connection/request.ex @@ -6,7 +6,7 @@ defmodule RethinkDB.Connection.Request do def make_request(query, token, from, state = %{pending: pending, socket: socket}) do new_pending = case from do :noreply -> pending - _ -> Dict.put_new(pending, token, from) + _ -> Map.put_new(pending, token, from) end bsize = :erlang.size(query) payload = token <> << bsize :: little-size(32) >> <> query @@ -41,7 +41,7 @@ defmodule RethinkDB.Connection.Request do case leftover <> data do << response :: binary-size(length), leftover :: binary >> -> Connection.reply(pending[token], {response, token}) - handle_recv("", %{state | current: {:start, leftover}, pending: Dict.delete(pending, token)}) + handle_recv("", %{state | current: {:start, leftover}, pending: Map.delete(pending, token)}) new_data -> {:noreply, %{state | current: {:length, length, token, new_data}}} end diff --git a/lib/rethinkdb/prepare.ex b/lib/rethinkdb/prepare.ex index 10cf96a..63160e2 100644 --- a/lib/rethinkdb/prepare.ex +++ b/lib/rethinkdb/prepare.ex @@ -28,15 +28,15 @@ defmodule RethinkDB.Prepare do {Enum.into(map, %{}), state} end defp prepare(ref, state = {max, map}) when is_reference(ref) do - case Dict.get(map,ref) do - nil -> {max + 1, {max + 1, Dict.put_new(map, ref, max + 1)}} + case Map.get(map, ref) do + nil -> {max + 1, {max + 1, Map.put_new(map, ref, max + 1)}} x -> {x, state} end end - defp prepare({k,v}, state) do + defp prepare({k, v}, state) do {k, state} = prepare(k, state) {v, state} = prepare(v, state) - {[k,v], state} + {[k, v], state} end defp prepare(el, state) do {el, state} diff --git a/lib/rethinkdb/query.ex b/lib/rethinkdb/query.ex index cf1d4eb..06fafc0 100644 --- a/lib/rethinkdb/query.ex +++ b/lib/rethinkdb/query.ex @@ -1860,7 +1860,7 @@ defmodule RethinkDB.Query do args = case arity do 0 -> [] - _ -> Enum.map(1..arity, fn _ -> make_ref end) + _ -> Enum.map(1..arity, fn _ -> make_ref() end) end params = Enum.map(args, &var/1) diff --git a/mix.exs b/mix.exs index 60baf53..ff9e0aa 100644 --- a/mix.exs +++ b/mix.exs @@ -5,8 +5,8 @@ defmodule RethinkDB.Mixfile do use Mix.Project version: "0.4.0", elixir: "~> 1.0", description: "RethinkDB driver for Elixir", - package: package, - deps: deps, + package: package(), + deps: deps(), test_coverage: [tool: ExCoveralls]] end diff --git a/test/changes_test.exs b/test/changes_test.exs index 36f7b2e..6636499 100644 --- a/test/changes_test.exs +++ b/test/changes_test.exs @@ -6,10 +6,10 @@ defmodule ChangesTest do @table_name "changes_test_table_1" setup_all do - start_link + start_link() table_create(@table_name) |> run on_exit fn -> - start_link + start_link() table_drop(@table_name) |> run end :ok @@ -43,18 +43,18 @@ defmodule ChangesTest do q = table(@table_name) |> insert(data) {:ok, res} = run(q) expected = res.data["id"] - {:ok, changes} = Task.await(t) + {:ok, changes} = Task.await(t) ^expected = changes.data |> hd |> Map.get("id") # test Enumerable t = Task.async fn -> - changes |> Enum.take(5) + changes |> Enum.take(5) end 1..6 |> Enum.each(fn _ -> q = table(@table_name) |> insert(data) run(q) end) - data = Task.await(t) + data = Task.await(t) 5 = Enum.count(data) end diff --git a/test/connection_test.exs b/test/connection_test.exs index e95c2c8..0c589a6 100644 --- a/test/connection_test.exs +++ b/test/connection_test.exs @@ -29,10 +29,10 @@ defmodule ConnectionTest do test "reconnects if initial connect fails" do {:ok, c} = start_link(port: 28014) Process.unlink(c) - %RethinkDB.Exception.ConnectionClosed{} = table_list |> run + %RethinkDB.Exception.ConnectionClosed{} = table_list() |> run conn = FlakyConnection.start('localhost', 28015, [local_port: 28014]) :timer.sleep(1000) - {:ok, %RethinkDB.Record{}} = RethinkDB.Query.table_list |> run + {:ok, %RethinkDB.Record{}} = RethinkDB.Query.table_list() |> run ref = Process.monitor(c) FlakyConnection.stop(conn) receive do @@ -47,7 +47,7 @@ defmodule ConnectionTest do table = "foo_flaky_test" RethinkDB.Query.table_create(table)|> run on_exit fn -> - start_link + start_link() :timer.sleep(100) RethinkDB.Query.table_drop(table) |> run GenServer.cast(__MODULE__, :stop) @@ -84,7 +84,7 @@ defmodule ConnectionTest do {:ok, c} = RethinkDB.Connection.start_link(db: "new_test") db_create("new_test") |> RethinkDB.run(c) db("new_test") |> table_create("new_test_table") |> RethinkDB.run(c) - {:ok, %{data: data}} = table_list |> RethinkDB.run(c) + {:ok, %{data: data}} = table_list() |> RethinkDB.run(c) assert data == ["new_test_table"] end @@ -92,7 +92,7 @@ defmodule ConnectionTest do {:ok, c} = RethinkDB.Connection.start_link(max_pending: 1) res = Enum.map(1..100, fn (_) -> Task.async fn -> - now |> RethinkDB.run(c) + now() |> RethinkDB.run(c) end end) |> Enum.map(&Task.await/1) assert Enum.any?(res, &(&1 == %RethinkDB.Exception.TooManyRequests{})) @@ -109,7 +109,7 @@ defmodule ConnectionTest do test "ssl connection" do conn = FlakyConnection.start('localhost', 28015, [ssl: [keyfile: "./test/cert/host.key", certfile: "./test/cert/host.crt"]]) {:ok, c} = RethinkDB.Connection.start_link(port: conn.port, ssl: [ca_certs: ["./test/cert/rootCA.pem"]], sync_connect: true) - {:ok, %{data: _}} = table_list |> RethinkDB.run(c) + {:ok, %{data: _}} = table_list() |> RethinkDB.run(c) end end @@ -119,7 +119,7 @@ defmodule ConnectionRunTest do import RethinkDB.Query setup_all do - start_link + start_link() :ok end @@ -127,7 +127,7 @@ defmodule ConnectionRunTest do db_create("db_option_test") |> run table_create("db_option_test_table") |> run(db: "db_option_test") - {:ok, %{data: data}} = db("db_option_test") |> table_list |> run + {:ok, %{data: data}} = db("db_option_test") |> table_list() |> run db_drop("db_option_test") |> run @@ -149,7 +149,7 @@ defmodule ConnectionRunTest do test "run with :noreply option" do :ok = make_array([1,2,3]) |> run(noreply: true) - noreply_wait + noreply_wait() end test "run with :profile options" do diff --git a/test/prepare_test.exs b/test/prepare_test.exs index f5c94c2..9541f91 100644 --- a/test/prepare_test.exs +++ b/test/prepare_test.exs @@ -4,25 +4,25 @@ defmodule PrepareTest do test "single elements" do assert prepare(1) == 1 - assert prepare(make_ref) == 1 + assert prepare(make_ref()) == 1 end test "list" do assert prepare([1,2,3]) == [1,2,3] - assert prepare([1,2,make_ref,make_ref]) == [1,2,1,2] + assert prepare([1,2,make_ref(),make_ref()]) == [1,2,1,2] end test "nested list" do list = [1, [1,2], [1, [1, 2]]] assert prepare(list) == list - list = [1, [make_ref, make_ref], make_ref, [1, 2]] + list = [1, [make_ref(), make_ref()], make_ref(), [1, 2]] assert prepare(list) == [1, [1, 2], 3, [1, 2]] end test "map" do map = %{a: 1, b: 2} assert prepare(map) == map - map = %{a: 1, b: make_ref, c: make_ref} + map = %{a: 1, b: make_ref(), c: make_ref()} assert prepare(map) == %{a: 1, b: 1, c: 2} end end diff --git a/test/query/administration_query_test.exs b/test/query/administration_query_test.exs index b3fadef..b913113 100644 --- a/test/query/administration_query_test.exs +++ b/test/query/administration_query_test.exs @@ -4,7 +4,7 @@ defmodule AdministrationQueryTest do import RethinkDB.Query setup_all do - start_link + start_link() :ok end @@ -16,7 +16,7 @@ defmodule AdministrationQueryTest do end :ok end - + test "config" do {:ok, r} = table(@table_name) |> config |> run assert %RethinkDB.Record{data: %{"db" => "test"}} = r diff --git a/test/query/aggregation_test.exs b/test/query/aggregation_test.exs index bd5d716..899e005 100644 --- a/test/query/aggregation_test.exs +++ b/test/query/aggregation_test.exs @@ -10,7 +10,7 @@ defmodule AggregationTest do import RethinkDB.Lambda setup_all do - start_link + start_link() :ok end diff --git a/test/query/control_structures_adv_test.exs b/test/query/control_structures_adv_test.exs index d10cdb5..fcd19ab 100644 --- a/test/query/control_structures_adv_test.exs +++ b/test/query/control_structures_adv_test.exs @@ -7,11 +7,11 @@ defmodule ControlStructuresAdvTest do @table_name "control_test_table_1" setup_all do - start_link + start_link() q = table_create(@table_name) run(q) on_exit fn -> - start_link + start_link() table_drop(@table_name) |> run end :ok diff --git a/test/query/control_structures_test.exs b/test/query/control_structures_test.exs index 13e65d7..549e4da 100644 --- a/test/query/control_structures_test.exs +++ b/test/query/control_structures_test.exs @@ -7,7 +7,7 @@ defmodule ControlStructuresTest do alias RethinkDB.Response setup_all do - start_link + start_link() :ok end @@ -39,10 +39,10 @@ defmodule ControlStructuresTest do test "branch" do q = branch(true, 1, 2) {:ok, %Record{data: data}} = run q - assert data == 1 + assert data == 1 q = branch(false, 1, 2) {:ok, %Record{data: data}} = run q - assert data == 2 + assert data == 2 end test "error" do @@ -105,7 +105,7 @@ defmodule ControlStructuresTest do end test "uuid" do - q = uuid + q = uuid() {:ok, %Record{data: data}} = run q assert String.length(String.replace(data, "-", "")) == 32 end diff --git a/test/query/database_test.exs b/test/query/database_test.exs index a2d0dcc..6d52096 100644 --- a/test/query/database_test.exs +++ b/test/query/database_test.exs @@ -6,7 +6,7 @@ defmodule DatabaseTest do alias RethinkDB.Record setup_all do - start_link + start_link() :ok end @@ -29,14 +29,14 @@ defmodule DatabaseTest do q = db_create(@db_name) {:ok, %Record{data: %{"dbs_created" => 1}}} = run(q) - q = db_list + q = db_list() {:ok, %Record{data: dbs}} = run(q) assert Enum.member?(dbs, @db_name) q = db_drop(@db_name) {:ok, %Record{data: %{"dbs_dropped" => 1}}} = run(q) - q = db_list + q = db_list() {:ok, %Record{data: dbs}} = run(q) assert !Enum.member?(dbs, @db_name) end diff --git a/test/query/date_time_test.exs b/test/query/date_time_test.exs index 27bfd50..386058b 100644 --- a/test/query/date_time_test.exs +++ b/test/query/date_time_test.exs @@ -7,12 +7,12 @@ defmodule DateTimeTest do alias RethinkDB.Pseudotypes.Time setup_all do - start_link + start_link() :ok end test "now" do - {:ok, %Record{data: data}} = now |> run + {:ok, %Record{data: data}} = now() |> run assert %Time{} = data end diff --git a/test/query/document_manipulation_test.exs b/test/query/document_manipulation_test.exs index 4572e2f..30d43c7 100644 --- a/test/query/document_manipulation_test.exs +++ b/test/query/document_manipulation_test.exs @@ -6,7 +6,7 @@ defmodule DocumentManipulationTest do alias RethinkDB.Record setup_all do - start_link + start_link() :ok end diff --git a/test/query/geospatial_adv_test.exs b/test/query/geospatial_adv_test.exs index bc09c62..df321ba 100644 --- a/test/query/geospatial_adv_test.exs +++ b/test/query/geospatial_adv_test.exs @@ -7,12 +7,12 @@ defmodule GeospatialAdvTest do @table_name "geo_test_table_1" setup_all do - start_link + start_link() table_create(@table_name) |> run table(@table_name) |> index_create("location", geo: true) |> run table(@table_name) |> index_wait("location") |> run on_exit fn -> - start_link + start_link() table_drop(@table_name) |> run end :ok diff --git a/test/query/geospatial_test.exs b/test/query/geospatial_test.exs index d5bc5c3..3c47034 100644 --- a/test/query/geospatial_test.exs +++ b/test/query/geospatial_test.exs @@ -9,7 +9,7 @@ defmodule GeospatialTest do alias RethinkDB.Pseudotypes.Geometry.Polygon setup_all do - start_link + start_link() :ok end diff --git a/test/query/joins_test.exs b/test/query/joins_test.exs index 6b28e1a..914a00f 100644 --- a/test/query/joins_test.exs +++ b/test/query/joins_test.exs @@ -11,10 +11,10 @@ defmodule JoinsTest do @table_name "joins_test_table_1" setup_all do - start_link + start_link() table_create(@table_name) |> run on_exit fn -> - start_link + start_link() table_drop(@table_name) |> run end :ok diff --git a/test/query/math_logic_test.exs b/test/query/math_logic_test.exs index 505a03a..2bf6c50 100644 --- a/test/query/math_logic_test.exs +++ b/test/query/math_logic_test.exs @@ -4,9 +4,9 @@ defmodule MathLogicTest do import RethinkDB.Query alias RethinkDB.Record - + setup_all do - start_link + start_link() :ok end @@ -76,7 +76,7 @@ defmodule MathLogicTest do test "find remainder when dividing two numbers" do {:ok, %Record{data: data}} = mod(23, 4) |> run - assert data == 3 + assert data == 3 end test "logical and of two values" do @@ -86,7 +86,7 @@ defmodule MathLogicTest do test "logical and of list" do {:ok, %Record{data: data}} = and_r([true, true, false]) |> run - assert data == false + assert data == false end test "logical or of two values" do @@ -96,89 +96,89 @@ defmodule MathLogicTest do test "logical or of list" do {:ok, %Record{data: data}} = or_r([false, false, false]) |> run - assert data == false + assert data == false end test "two numbers are equal" do {:ok, %Record{data: data}} = eq(1, 1) |> run - assert data == true + assert data == true {:ok, %Record{data: data}} = eq(2, 1) |> run - assert data == false + assert data == false end - + test "values in a list are equal" do {:ok, %Record{data: data}} = eq([1, 1, 1]) |> run - assert data == true + assert data == true {:ok, %Record{data: data}} = eq([1, 2, 1]) |> run - assert data == false + assert data == false end - + test "two numbers are not equal" do {:ok, %Record{data: data}} = ne(1, 1) |> run - assert data == false + assert data == false {:ok, %Record{data: data}} = ne(2, 1) |> run - assert data == true + assert data == true end - + test "values in a list are not equal" do {:ok, %Record{data: data}} = ne([1, 1, 1]) |> run - assert data == false + assert data == false {:ok, %Record{data: data}} = ne([1, 2, 1]) |> run assert data == true end - + test "a number is less than the other" do {:ok, %Record{data: data}} = lt(2, 1) |> run - assert data == false + assert data == false {:ok, %Record{data: data}} = lt(1, 2) |> run - assert data == true + assert data == true end - + test "values in a list less than the next" do {:ok, %Record{data: data}} = lt([1, 4, 2]) |> run - assert data == false + assert data == false {:ok, %Record{data: data}} = lt([1, 4, 5]) |> run assert data == true end - + test "a number is less than or equal to the other" do {:ok, %Record{data: data}} = le(1, 1) |> run - assert data == true + assert data == true {:ok, %Record{data: data}} = le(1, 2) |> run - assert data == true + assert data == true end - + test "values in a list less than or equal to the next" do {:ok, %Record{data: data}} = le([1, 4, 2]) |> run - assert data == false + assert data == false {:ok, %Record{data: data}} = le([1, 4, 4]) |> run assert data == true end - + test "a number is greater than the other" do {:ok, %Record{data: data}} = gt(1, 1) |> run - assert data == false + assert data == false {:ok, %Record{data: data}} = gt(2, 1) |> run - assert data == true + assert data == true end - + test "values in a list greater than the next" do {:ok, %Record{data: data}} = gt([1, 4, 2]) |> run - assert data == false + assert data == false {:ok, %Record{data: data}} = gt([10, 4, 2]) |> run assert data == true end - + test "a number is greater than or equal to the other" do {:ok, %Record{data: data}} = ge(1, 1) |> run - assert data == true + assert data == true {:ok, %Record{data: data}} = ge(2, 1) |> run - assert data == true + assert data == true end - + test "values in a list greater than or equal to the next" do {:ok, %Record{data: data}} = ge([1, 4, 2]) |> run - assert data == false + assert data == false {:ok, %Record{data: data}} = ge([10, 4, 4]) |> run assert data == true end @@ -189,7 +189,7 @@ defmodule MathLogicTest do end test "random operator" do - {:ok, %Record{data: data}} = random |> run + {:ok, %Record{data: data}} = random() |> run assert data >= 0.0 && data <= 1.0 {:ok, %Record{data: data}} = random(100) |> run assert is_integer(data) && data >= 0 && data <= 100 @@ -217,7 +217,7 @@ defmodule MathLogicTest do test "floor" do {:ok, %Record{data: data}} = floor(0.3) |> run - assert data == 0 + assert data == 0 {:ok, %Record{data: data}} = floor(0.6) |> run assert data == 0 end diff --git a/test/query/selection_test.exs b/test/query/selection_test.exs index 922b0eb..53b7fae 100644 --- a/test/query/selection_test.exs +++ b/test/query/selection_test.exs @@ -10,10 +10,10 @@ defmodule SelectionTest do @table_name "selection_test_table_1" setup_all do - start_link + start_link() table_create(@table_name) |> run on_exit fn -> - start_link + start_link() table_drop(@table_name) |> run end :ok @@ -63,7 +63,7 @@ defmodule SelectionTest do table(@table_name) |> insert(%{id: "c", a: 5}) |> run {:ok, %RethinkDB.Collection{data: data}} = table(@table_name) |> between("b", "d") |> run assert Enum.count(data) == 2 - {:ok, %RethinkDB.Collection{data: data}} = table(@table_name) |> between(minval, maxval) |> run + {:ok, %RethinkDB.Collection{data: data}} = table(@table_name) |> between(minval(), maxval()) |> run assert Enum.count(data) == 3 end diff --git a/test/query/string_manipulation_test.exs b/test/query/string_manipulation_test.exs index 7eec1f3..8e721f2 100644 --- a/test/query/string_manipulation_test.exs +++ b/test/query/string_manipulation_test.exs @@ -4,9 +4,9 @@ defmodule StringManipulationTest do import RethinkDB.Query alias RethinkDB.Record - + setup_all do - {:ok, pid} = RethinkDB.Connection.start_link + {:ok, pid} = RethinkDB.Connection.start_link() {:ok, %{conn: pid}} end diff --git a/test/query/table_db_test.exs b/test/query/table_db_test.exs index 4558a9e..d07339d 100644 --- a/test/query/table_db_test.exs +++ b/test/query/table_db_test.exs @@ -6,10 +6,10 @@ defmodule TableDBTest do alias RethinkDB.Record setup_all do - start_link + start_link() :ok end - + @db_name "table_db_test_db_1" @table_name "table_db_test_table_1" diff --git a/test/query/table_index_test.exs b/test/query/table_index_test.exs index 0e5c790..c89bd23 100644 --- a/test/query/table_index_test.exs +++ b/test/query/table_index_test.exs @@ -5,10 +5,10 @@ defmodule TableIndexTest do alias RethinkDB.Record setup_all do - start_link + start_link() :ok end - + @table_name "table_index_test_table_1" setup do table_create(@table_name) |> run diff --git a/test/query/table_test.exs b/test/query/table_test.exs index 25aec55..9020cf7 100644 --- a/test/query/table_test.exs +++ b/test/query/table_test.exs @@ -5,10 +5,10 @@ defmodule TableTest do alias RethinkDB.Record setup_all do - start_link + start_link() :ok end - + @table_name "table_test_table_1" test "tables" do @@ -19,14 +19,14 @@ defmodule TableTest do q = table_create(@table_name) {:ok, %Record{data: %{"tables_created" => 1}}} = run q - q = table_list + q = table_list() {:ok, %Record{data: tables}} = run q assert Enum.member?(tables, @table_name) q = table_drop(@table_name) {:ok, %Record{data: %{"tables_dropped" => 1}}} = run q - q = table_list + q = table_list() {:ok, %Record{data: tables}} = run q assert !Enum.member?(tables, @table_name) diff --git a/test/query/transformation_test.exs b/test/query/transformation_test.exs index 3d6d38d..2e01191 100644 --- a/test/query/transformation_test.exs +++ b/test/query/transformation_test.exs @@ -10,7 +10,7 @@ defmodule TransformationTest do import RethinkDB.Lambda setup_all do - start_link + start_link() :ok end diff --git a/test/query/writing_data_test.exs b/test/query/writing_data_test.exs index 1a37d3b..5828304 100644 --- a/test/query/writing_data_test.exs +++ b/test/query/writing_data_test.exs @@ -8,10 +8,10 @@ defmodule WritingDataTest do @table_name "writing_data_test_table_1" setup_all do - start_link + start_link() table_create(@table_name) |> run on_exit fn -> - start_link + start_link() table_drop(@table_name) |> run end :ok @@ -43,9 +43,9 @@ defmodule WritingDataTest do test "insert conflict options" do table_query = table(@table_name) - q = insert(table_query, [%{name: "Hello", value: 1}]) + q = insert(table_query, [%{name: "Hello", value: 1}]) {:ok, %Record{data: %{"generated_keys"=> [id], "inserted" => 1}}} = run(q) - + q = insert(table_query, [%{name: "Hello", id: id, value: 2}]) {:ok, %Record{data: %{"errors" => 1}}} = run(q) @@ -57,11 +57,11 @@ defmodule WritingDataTest do {:ok, %Record{data: %{"replaced" => 1}}} = run(q) {:ok, %Collection{data: [%{"id" => ^id, "name" => "World", "value" => 3}]}} = run(table_query) - q = insert(table_query, [%{id: id, value: 3}], %{conflict: fn(_id, old, new) -> + q = insert(table_query, [%{id: id, value: 3}], %{conflict: fn(_id, old, new) -> merge(old, %{value: add(get_field(old, "value"), get_field(new, "value"))}) end}) {:ok, %Record{data: %{"replaced" => 1}}} = run(q) {:ok, %Collection{data: [%{"id" => ^id, "name" => "World", "value" => 6}]}} = run(table_query) - end + end test "update" do table_query = table(@table_name) diff --git a/test/query_test.exs b/test/query_test.exs index 42f4389..ccdfa42 100644 --- a/test/query_test.exs +++ b/test/query_test.exs @@ -9,10 +9,10 @@ defmodule QueryTest do @table_name "query_test_table_1" setup_all do - start_link + start_link() table_create(@table_name) |> run on_exit fn -> - start_link + start_link() table_drop(@table_name) |> run end :ok From c5631e8de47f0b653c187f13bc974844304e05e0 Mon Sep 17 00:00:00 2001 From: Russell Matney Date: Sat, 11 Mar 2017 12:40:25 -0500 Subject: [PATCH 2/2] build(travis): update travis config to elixir 1.4 --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 3b4adb2..b805cf3 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,7 +1,7 @@ language: elixir elixir: - - 1.3 + - 1.4 otp_release: - 18.3