diff --git a/README.md b/README.md index c40784a..be2d58b 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,7 @@ by adding `lexdee` to your list of dependencies in `mix.exs`: ```elixir def deps do [ - {:lexdee, "~> 0.1.0"} + {:lexdee, "~> 1.0.0"} ] end ``` diff --git a/lib/lexdee.ex b/lib/lexdee.ex index 3da8131..a0e1a7f 100644 --- a/lib/lexdee.ex +++ b/lib/lexdee.ex @@ -41,7 +41,7 @@ defmodule Lexdee do alias Cluster.Members - defdelegate get_cluster_members(client), to: Members, as: :index + defdelegate list_cluster_members(client, opts \\ []), to: Members, as: :index defdelegate get_cluster_member(client, id), to: Members, as: :show alias Lexdee.Instances diff --git a/lib/lexdee/cluster/members.ex b/lib/lexdee/cluster/members.ex index 3402c1d..3e30045 100644 --- a/lib/lexdee/cluster/members.ex +++ b/lib/lexdee/cluster/members.ex @@ -3,6 +3,6 @@ defmodule Lexdee.Cluster.Members do use Lexdee.Utils - def index(client), do: Tesla.get(client, @path) + def index(client, options \\ []), do: Tesla.get(client, @path, options) def show(client, id), do: Tesla.get(client, get_id(id)) end diff --git a/mix.exs b/mix.exs index 96d9cff..9f49c96 100644 --- a/mix.exs +++ b/mix.exs @@ -4,7 +4,7 @@ defmodule Lexdee.MixProject do def project do [ app: :lexdee, - version: "1.0.4", + version: "1.0.5", elixir: "~> 1.9", start_permanent: Mix.env() == :prod, package: package(), diff --git a/test/lexdee/cluster/members_test.exs b/test/lexdee/cluster/members_test.exs index aecd6bb..45363e2 100644 --- a/test/lexdee/cluster/members_test.exs +++ b/test/lexdee/cluster/members_test.exs @@ -1,6 +1,37 @@ defmodule Lexdee.Cluster.MembersTest do use ExUnit.Case + describe "index recursive 1" do + setup do + response = + File.read!( + "test/support/fixtures/responses/cluster/member/index_recursive_one.json" + ) + + bypass = Bypass.open() + client = Lexdee.create_client("http://localhost:#{bypass.port}") + + {:ok, client: client, bypass: bypass, response: response} + end + + test "return success list cluster members", %{ + bypass: bypass, + client: client, + response: response + } do + Bypass.expect(bypass, "GET", "/1.0/cluster/members", fn conn -> + %{"recursion" => "1"} = conn.query_params + + conn + |> Plug.Conn.put_resp_header("content-type", "application/json") + |> Plug.Conn.resp(200, response) + end) + + assert {:ok, _data} = + Lexdee.list_cluster_members(client, query: [recursion: 1]) + end + end + describe "show member" do setup do response = diff --git a/test/support/fixtures/responses/cluster/member/index_recursive_one.json b/test/support/fixtures/responses/cluster/member/index_recursive_one.json new file mode 100644 index 0000000..20df27e --- /dev/null +++ b/test/support/fixtures/responses/cluster/member/index_recursive_one.json @@ -0,0 +1,24 @@ +{ + "type": "sync", + "status": "Success", + "status_code": 200, + "operation": "", + "error_code": 0, + "error": "", + "metadata": [ + { + "roles": [ + "database" + ], + "failure_domain": "", + "description": "", + "config": null, + "server_name": "ubuntu-s-1vcpu-1gb-sgp1-01", + "url": "https://10.130.0.3:8443", + "database": true, + "status": "Online", + "message": "Fully operational", + "architecture": "x86_64" + } + ] +} \ No newline at end of file