From b319e08ab30b5d84caf979cdb232f300a57d47db Mon Sep 17 00:00:00 2001 From: Yordis Prieto Lazo Date: Fri, 6 Jan 2023 12:21:41 -0500 Subject: [PATCH] chore: add dialyzer to pipeline fix typespec remove comment fix credo chore use .tool-versions file in ci update deps fix formatter fix credo improve type format code fix version of jason --- .github/workflows/ci.yml | 67 ++++++++++++++++++++------------ .gitignore | 4 +- .tool-versions | 4 +- lib/spear.ex | 2 +- lib/spear/connection.ex | 14 +++---- lib/spear/connection/request.ex | 4 +- lib/spear/connection/response.ex | 7 ++++ lib/spear/reading/stream.ex | 2 +- mix.exs | 17 +++++--- mix.lock | 18 +++++---- priv/plts/.gitignore | 1 + test/spear/connection_test.exs | 18 +++------ 12 files changed, 93 insertions(+), 65 deletions(-) create mode 100644 priv/plts/.gitignore diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 095dcc5..2f1d0cd 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -20,35 +20,30 @@ jobs: - name: Spawn docker-compose EventStoreDB container run: docker-compose up --detach eventstore - - name: Determine the elixir version - run: echo "ELIXIR_VERSION=$(grep -h elixir .tool-versions | awk '{ print $2 }' | awk -F - '{print $1}')" >> $GITHUB_ENV - - - name: Determine the otp version - run: echo "OTP_VERSION=$(grep -h erlang .tool-versions | awk '{ print $2 }')" >> $GITHUB_ENV - - name: Setup Elixir and Erlang versions uses: erlef/setup-beam@v1 + id: beam with: - otp-version: ${{ env.OTP_VERSION }} - elixir-version: ${{ env.ELIXIR_VERSION }} + version-file: .tool-versions + version-type: strict - name: Restore the deps cache uses: actions/cache@v3 id: deps-cache with: path: deps - key: ${{ runner.os }}-${{ env.ELIXIR_VERSION }}-${{ env.OTP_VERSION }}-${{ env.MIX_ENV }}-deps-mixlockhash-${{ hashFiles(format('{0}{1}', github.workspace, '/mix.lock')) }} + key: ${{ runner.os }}-${{ steps.beam.outputs.elixir-version }}-${{ steps.beam.outputs.otp-version }}-${{ env.MIX_ENV }}-deps-mixlockhash-${{ hashFiles(format('{0}{1}', github.workspace, '/mix.lock')) }} restore-keys: | - ${{ runner.os }}-${{ env.ELIXIR_VERSION }}-${{ env.OTP_VERSION }}-${{ env.MIX_ENV }}-deps- + ${{ runner.os }}-${{ steps.beam.outputs.elixir-version }}-${{ steps.beam.outputs.otp-version }}-${{ env.MIX_ENV }}-deps- - name: Restore the _build cache uses: actions/cache@v3 id: build-cache with: path: _build - key: ${{ runner.os }}-${{ env.ELIXIR_VERSION }}-${{ env.OTP_VERSION }}-${{ env.MIX_ENV }}-build-mixlockhash-${{ hashFiles(format('{0}{1}', github.workspace, '/mix.lock')) }} + key: ${{ runner.os }}-${{ steps.beam.outputs.elixir-version }}-${{ steps.beam.outputs.otp-version }}-${{ env.MIX_ENV }}-build-mixlockhash-${{ hashFiles(format('{0}{1}', github.workspace, '/mix.lock')) }} restore-keys: | - ${{ runner.os }}-${{ env.ELIXIR_VERSION }}-${{ env.OTP_VERSION }}-${{ env.MIX_ENV }}-build- + ${{ runner.os }}-${{ steps.beam.outputs.elixir-version }}-${{ steps.beam.outputs.otp-version }}-${{ env.MIX_ENV }}-build- - name: Fetch mix dependencies if: steps.deps-cache.outputs.cache-hit != 'true' @@ -75,6 +70,35 @@ jobs: - name: Credo run: mix credo + - name: Restore PLT cache + uses: actions/cache/restore@v3 + id: plt_cache + with: + key: | + ${{ runner.os }}-${{ steps.beam.outputs.elixir-version }}-${{ steps.beam.outputs.otp-version }}-plt + restore-keys: | + ${{ runner.os }}-${{ steps.beam.outputs.elixir-version }}-${{ steps.beam.outputs.otp-version }}-plt + path: | + priv/plts + + - name: Create PLTs + shell: sh + if: steps.plt_cache.outputs.cache-hit != 'true' + run: mix dialyzer --plt + + - name: Save PLT cache + uses: actions/cache/save@v3 + if: steps.plt_cache.outputs.cache-hit != 'true' + id: plt_cache_save + with: + key: | + ${{ runner.os }}-${{ steps.beam.outputs.elixir-version }}-${{ steps.beam.outputs.otp-version }}-plt + path: | + priv/plts + + - name: Run dialyzer + run: mix dialyzer --format github + publish-hex-package: name: Publish Hex Package ⬆️☁️ runs-on: ubuntu-20.04 @@ -88,35 +112,30 @@ jobs: - name: Checkout uses: actions/checkout@v3 - - name: Determine the elixir version - run: echo "ELIXIR_VERSION=$(grep -h elixir .tool-versions | awk '{ print $2 }' | awk -F - '{print $1}')" >> $GITHUB_ENV - - - name: Determine the otp version - run: echo "OTP_VERSION=$(grep -h erlang .tool-versions | awk '{ print $2 }')" >> $GITHUB_ENV - - name: Setup Elixir and Erlang versions uses: erlef/setup-beam@v1 + id: beam with: - otp-version: ${{ env.OTP_VERSION }} - elixir-version: ${{ env.ELIXIR_VERSION }} + version-file: .tool-versions + version-type: strict - name: Restore the deps cache uses: actions/cache@v3 id: deps-cache with: path: deps - key: ${{ runner.os }}-${{ env.ELIXIR_VERSION }}-${{ env.OTP_VERSION }}-${{ env.MIX_ENV }}-deps-mixlockhash-${{ hashFiles(format('{0}{1}', github.workspace, '/mix.lock')) }} + key: ${{ runner.os }}-${{ steps.beam.outputs.elixir-version }}-${{ steps.beam.outputs.otp-version }}-${{ env.MIX_ENV }}-deps-mixlockhash-${{ hashFiles(format('{0}{1}', github.workspace, '/mix.lock')) }} restore-keys: | - ${{ runner.os }}-${{ env.ELIXIR_VERSION }}-${{ env.OTP_VERSION }}-${{ env.MIX_ENV }}-deps- + ${{ runner.os }}-${{ steps.beam.outputs.elixir-version }}-${{ steps.beam.outputs.otp-version }}-${{ env.MIX_ENV }}-deps- - name: Restore the _build cache uses: actions/cache@v3 id: build-cache with: path: _build - key: ${{ runner.os }}-${{ env.ELIXIR_VERSION }}-${{ env.OTP_VERSION }}-${{ env.MIX_ENV }}-build-mixlockhash-${{ hashFiles(format('{0}{1}', github.workspace, '/mix.lock')) }} + key: ${{ runner.os }}-${{ steps.beam.outputs.elixir-version }}-${{ steps.beam.outputs.otp-version }}-${{ env.MIX_ENV }}-build-mixlockhash-${{ hashFiles(format('{0}{1}', github.workspace, '/mix.lock')) }} restore-keys: | - ${{ runner.os }}-${{ env.ELIXIR_VERSION }}-${{ env.OTP_VERSION }}-${{ env.MIX_ENV }}-build- + ${{ runner.os }}-${{ steps.beam.outputs.elixir-version }}-${{ steps.beam.outputs.otp-version }}-${{ env.MIX_ENV }}-build- - name: Fetch mix dependencies if: steps.deps-cache.outputs.cache-hit != 'true' diff --git a/.gitignore b/.gitignore index e89b9eb..00a75bf 100644 --- a/.gitignore +++ b/.gitignore @@ -22,6 +22,8 @@ erl_crash.dump # Ignore package tarball (built via "mix hex.build"). spear-*.tar - # Temporary files for e.g. tests /tmp + +/priv/plts/*.plt +/priv/plts/*.plt.hash diff --git a/.tool-versions b/.tool-versions index 93a429b..f08de31 100644 --- a/.tool-versions +++ b/.tool-versions @@ -1,2 +1,2 @@ -elixir 1.12.3-otp-24 -erlang 24.0 +elixir 1.14.5-otp-26 +erlang 26.0 diff --git a/lib/spear.ex b/lib/spear.ex index 34a21fa..faaa60b 100644 --- a/lib/spear.ex +++ b/lib/spear.ex @@ -1993,7 +1993,7 @@ defmodule Spear do stream_name :: String.t() | :all, group_name :: String.t(), opts :: Keyword.t() - ) :: {:ok, Spear.PersistentSubcription.Info.t()} | {:error, any()} + ) :: {:ok, Spear.PersistentSubscription.Info.t()} | {:error, any()} def get_persistent_subscription_info(conn, stream_name, group_name, opts \\ []) when (is_binary(stream_name) or stream_name == :all) and is_binary(group_name) do get_info_message = diff --git a/lib/spear/connection.ex b/lib/spear/connection.ex index 03d6efc..707cb2b 100644 --- a/lib/spear/connection.ex +++ b/lib/spear/connection.ex @@ -88,6 +88,8 @@ defmodule Spear.Connection do defstruct [:config, :conn, requests: %{}, keep_alive_timer: %KeepAliveTimer{}] + @type state :: %__MODULE__{} + @typedoc """ A connection process @@ -152,9 +154,7 @@ defmodule Spear.Connection do %Config{errors: errors} -> error_lines = - errors - |> Enum.map(fn {key, error} -> "\t#{inspect(key)}: #{error}" end) - |> Enum.join("\n") + Enum.map_join(errors, "\n", fn {key, error} -> "\t#{inspect(key)}: #{error}" end) Logger.error(""" Invalid configuration passed to #{inspect(__MODULE__)}. Found the following errors: @@ -327,10 +327,10 @@ defmodule Spear.Connection do def handle_info(:keep_alive_expired, s), do: {:disconnect, :keep_alive_timeout, s} def handle_info(message, s) do - with %Mint.HTTP2{} = conn <- s.conn, - {:ok, conn, responses} <- Mint.HTTP2.stream(conn, message) do - {:noreply, put_in(s.conn, conn) |> handle_responses(responses)} - else + case Mint.HTTP2.stream(s.conn, message) do + {:ok, conn, responses} -> + {:noreply, put_in(s.conn, conn) |> handle_responses(responses)} + # coveralls-ignore-start {:error, conn, reason, responses} -> s = put_in(s.conn, conn) |> handle_responses(responses) diff --git a/lib/spear/connection/request.ex b/lib/spear/connection/request.ex index e2a3622..024aa5f 100644 --- a/lib/spear/connection/request.ex +++ b/lib/spear/connection/request.ex @@ -77,8 +77,8 @@ defmodule Spear.Connection.Request do {[{message, message_size} | message_buffer], message_size + message_buffer_size, max_size}} end - @spec emit_messages(%Spear.Connection{}, %__MODULE__{}) :: - {:ok, %Spear.Connection{}} | {:error, %Spear.Connection{}, reason :: any()} + @spec emit_messages(Spear.Connection.state(), %__MODULE__{}) :: + {:ok, Spear.Connection.state()} | {:error, Spear.Connection.state(), reason :: any()} def emit_messages(state, %__MODULE__{status: :done, buffer: <<>>}), do: {:ok, state} def emit_messages(state, %__MODULE__{status: :done, buffer: buffer} = request) do diff --git a/lib/spear/connection/response.ex b/lib/spear/connection/response.ex index 2aa4ba1..9b14880 100644 --- a/lib/spear/connection/response.ex +++ b/lib/spear/connection/response.ex @@ -3,5 +3,12 @@ defmodule Spear.Connection.Response do # a slim data structure for storing information about an HTTP/2 response + @type t :: %__MODULE__{ + status: Mint.Types.status(), + type: {module(), atom()}, + headers: Mint.Types.headers(), + data: binary() + } + defstruct [:status, :type, headers: [], data: <<>>] end diff --git a/lib/spear/reading/stream.ex b/lib/spear/reading/stream.ex index 3bd4eb2..ce9e32a 100644 --- a/lib/spear/reading/stream.ex +++ b/lib/spear/reading/stream.ex @@ -82,7 +82,7 @@ defmodule Spear.Reading.Stream do response end - @spec unfold_chunk(binary()) :: {struct(), binary()} | nil + @spec unfold_chunk(binary()) :: {tuple(), binary()} | nil def unfold_chunk(buffer) when is_binary(buffer) do Spear.Grpc.decode_next_message( buffer, diff --git a/mix.exs b/mix.exs index 5c37f2c..539b61e 100644 --- a/mix.exs +++ b/mix.exs @@ -24,15 +24,18 @@ defmodule Spear.MixProject do "coveralls.github": :test, inch: :dev, bless: :test, - test: :test, - dialyzer: :test + test: :test ], name: "Spear", source_url: @source_url, deps: deps(), docs: docs(), package: package(), - description: description() + description: description(), + dialyzer: [ + plt_add_apps: [:jason], + plt_file: {:no_warn, "priv/plts/dialyzer.plt"} + ] ] end @@ -50,12 +53,14 @@ defmodule Spear.MixProject do {:event_store_db_gpb_protobufs, "~> 2.2"}, {:connection, "~> 1.0"}, # optional dependencies - {:jason, ">= 0.0.0", optional: true}, + {:jason, "~> 1.0", optional: true}, + # dev/test utilities {:castore, ">= 0.0.0", only: [:dev, :test]}, - {:ex_doc, "~> 0.24", only: :dev, runtime: false}, + {:ex_doc, ">= 0.0.0", only: :dev, runtime: false}, + {:dialyxir, ">= 0.0.0", only: [:dev, :test], runtime: false}, # testing suite - {:credo, "~> 1.5", only: :test}, + {:credo, "~> 1.6", only: :test}, {:bless, "~> 1.0", only: :test}, {:excoveralls, "~> 0.7", only: :test} ] diff --git a/mix.lock b/mix.lock index 99a4246..6cef76e 100644 --- a/mix.lock +++ b/mix.lock @@ -1,19 +1,21 @@ %{ "bless": {:hex, :bless, "1.1.0", "b27571e49a4ba22d92412184740b186448a27c3ddf2e9e687851e937932b5a60", [:mix], [], "hexpm", "ea5dc19a36609f927d4035a8409393cd3016b5c482245cffa30b3bd6669c617e"}, - "bunt": {:hex, :bunt, "0.2.0", "951c6e801e8b1d2cbe58ebbd3e616a869061ddadcc4863d0a2182541acae9a38", [:mix], [], "hexpm", "7af5c7e09fe1d40f76c8e4f9dd2be7cebd83909f31fee7cd0e9eadc567da8353"}, + "bunt": {:hex, :bunt, "0.2.1", "e2d4792f7bc0ced7583ab54922808919518d0e57ee162901a16a1b6664ef3b14", [:mix], [], "hexpm", "a330bfb4245239787b15005e66ae6845c9cd524a288f0d141c148b02603777a5"}, "castore": {:hex, :castore, "0.1.10", "b01a007416a0ae4188e70b3b306236021b16c11474038ead7aff79dd75538c23", [:mix], [], "hexpm", "a48314e0cb45682db2ea27b8ebfa11bd6fa0a6e21a65e5772ad83ca136ff2665"}, - "certifi": {:hex, :certifi, "2.6.1", "dbab8e5e155a0763eea978c913ca280a6b544bfa115633fa20249c3d396d9493", [:rebar3], [], "hexpm", "524c97b4991b3849dd5c17a631223896272c6b0af446778ba4675a1dff53bb7e"}, + "certifi": {:hex, :certifi, "2.9.0", "6f2a475689dd47f19fb74334859d460a2dc4e3252a3324bd2111b8f0429e7e21", [:rebar3], [], "hexpm", "266da46bdb06d6c6d35fde799bcb28d36d985d424ad7c08b5bb48f5b5cdd4641"}, "connection": {:hex, :connection, "1.1.0", "ff2a49c4b75b6fb3e674bfc5536451607270aac754ffd1bdfe175abe4a6d7a68", [:mix], [], "hexpm", "722c1eb0a418fbe91ba7bd59a47e28008a189d47e37e0e7bb85585a016b2869c"}, - "credo": {:hex, :credo, "1.5.6", "e04cc0fdc236fefbb578e0c04bd01a471081616e741d386909e527ac146016c6", [:mix], [{:bunt, "~> 0.2.0", [hex: :bunt, repo: "hexpm", optional: false]}, {:file_system, "~> 0.2.8", [hex: :file_system, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: false]}], "hexpm", "4b52a3e558bd64e30de62a648518a5ea2b6e3e5d2b164ef5296244753fc7eb17"}, - "earmark_parser": {:hex, :earmark_parser, "1.4.29", "149d50dcb3a93d9f3d6f3ecf18c918fb5a2d3c001b5d3305c926cddfbd33355b", [:mix], [], "hexpm", "4902af1b3eb139016aed210888748db8070b8125c2342ce3dcae4f38dcc63503"}, + "credo": {:hex, :credo, "1.6.7", "323f5734350fd23a456f2688b9430e7d517afb313fbd38671b8a4449798a7854", [:mix], [{:bunt, "~> 0.2.1", [hex: :bunt, repo: "hexpm", optional: false]}, {:file_system, "~> 0.2.8", [hex: :file_system, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: false]}], "hexpm", "41e110bfb007f7eda7f897c10bf019ceab9a0b269ce79f015d54b0dcf4fc7dd3"}, + "dialyxir": {:hex, :dialyxir, "1.2.0", "58344b3e87c2e7095304c81a9ae65cb68b613e28340690dfe1a5597fd08dec37", [:mix], [{:erlex, ">= 0.2.6", [hex: :erlex, repo: "hexpm", optional: false]}], "hexpm", "61072136427a851674cab81762be4dbeae7679f85b1272b6d25c3a839aff8463"}, + "earmark_parser": {:hex, :earmark_parser, "1.4.30", "0b938aa5b9bafd455056440cdaa2a79197ca5e693830b4a982beada840513c5f", [:mix], [], "hexpm", "3b5385c2d36b0473d0b206927b841343d25adb14f95f0110062506b300cd5a1b"}, + "erlex": {:hex, :erlex, "0.2.6", "c7987d15e899c7a2f34f5420d2a2ea0d659682c06ac607572df55a43753aa12e", [:mix], [], "hexpm", "2ed2e25711feb44d52b17d2780eabf998452f6efda104877a3881c2f8c0c0c75"}, "event_store_db_gpb_protobufs": {:hex, :event_store_db_gpb_protobufs, "2.2.0", "fca2bdeac5fca205e02d3cb9f170477a5422e147413d21d07c19e1ffc70e66aa", [:rebar3], [{:gpb, "~> 4.0", [hex: :gpb, repo: "hexpm", optional: false]}], "hexpm", "dad49149eb6913805277a698ec1f607aac945c40cbf427aa03cc97309fdf2f1f"}, - "ex_doc": {:hex, :ex_doc, "0.29.0", "4a1cb903ce746aceef9c1f9ae8a6c12b742a5461e6959b9d3b24d813ffbea146", [:mix], [{:earmark_parser, "~> 1.4.19", [hex: :earmark_parser, repo: "hexpm", optional: false]}, {:makeup_elixir, "~> 0.14", [hex: :makeup_elixir, repo: "hexpm", optional: false]}, {:makeup_erlang, "~> 0.1", [hex: :makeup_erlang, repo: "hexpm", optional: false]}], "hexpm", "f096adb8bbca677d35d278223361c7792d496b3fc0d0224c9d4bc2f651af5db1"}, - "excoveralls": {:hex, :excoveralls, "0.14.1", "14140e4ef343f2af2de33d35268c77bc7983d7824cb945e6c2af54235bc2e61f", [:mix], [{:hackney, "~> 1.16", [hex: :hackney, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: false]}], "hexpm", "4a588f9f8cf9dc140cc1f3d0ea4d849b2f76d5d8bee66b73c304bb3d3689c8b0"}, + "ex_doc": {:hex, :ex_doc, "0.29.1", "b1c652fa5f92ee9cf15c75271168027f92039b3877094290a75abcaac82a9f77", [:mix], [{:earmark_parser, "~> 1.4.19", [hex: :earmark_parser, repo: "hexpm", optional: false]}, {:makeup_elixir, "~> 0.14", [hex: :makeup_elixir, repo: "hexpm", optional: false]}, {:makeup_erlang, "~> 0.1", [hex: :makeup_erlang, repo: "hexpm", optional: false]}], "hexpm", "b7745fa6374a36daf484e2a2012274950e084815b936b1319aeebcf7809574f6"}, + "excoveralls": {:hex, :excoveralls, "0.15.3", "54bb54043e1cf5fe431eb3db36b25e8fd62cf3976666bafe491e3fa5e29eba47", [:mix], [{:hackney, "~> 1.16", [hex: :hackney, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: false]}], "hexpm", "f8eb5d8134d84c327685f7bb8f1db4147f1363c3c9533928234e496e3070114e"}, "file_system": {:hex, :file_system, "0.2.10", "fb082005a9cd1711c05b5248710f8826b02d7d1784e7c3451f9c1231d4fc162d", [:mix], [], "hexpm", "41195edbfb562a593726eda3b3e8b103a309b733ad25f3d642ba49696bf715dc"}, "gpb": {:hex, :gpb, "4.19.5", "ff9d434308fd205c07b662a86c37e9579a8c9a04ad511d2c4dd63430a59f4729", [:make, :rebar3], [], "hexpm", "21b76750d66b459ce40cb14298fb38ef8e0161d9b672a5284585c02563806f8e"}, - "hackney": {:hex, :hackney, "1.17.4", "99da4674592504d3fb0cfef0db84c3ba02b4508bae2dff8c0108baa0d6e0977c", [:rebar3], [{:certifi, "~>2.6.1", [hex: :certifi, repo: "hexpm", optional: false]}, {:idna, "~>6.1.0", [hex: :idna, repo: "hexpm", optional: false]}, {:metrics, "~>1.0.0", [hex: :metrics, repo: "hexpm", optional: false]}, {:mimerl, "~>1.1", [hex: :mimerl, repo: "hexpm", optional: false]}, {:parse_trans, "3.3.1", [hex: :parse_trans, repo: "hexpm", optional: false]}, {:ssl_verify_fun, "~>1.1.0", [hex: :ssl_verify_fun, repo: "hexpm", optional: false]}, {:unicode_util_compat, "~>0.7.0", [hex: :unicode_util_compat, repo: "hexpm", optional: false]}], "hexpm", "de16ff4996556c8548d512f4dbe22dd58a587bf3332e7fd362430a7ef3986b16"}, + "hackney": {:hex, :hackney, "1.18.1", "f48bf88f521f2a229fc7bae88cf4f85adc9cd9bcf23b5dc8eb6a1788c662c4f6", [:rebar3], [{:certifi, "~> 2.9.0", [hex: :certifi, repo: "hexpm", optional: false]}, {:idna, "~> 6.1.0", [hex: :idna, repo: "hexpm", optional: false]}, {:metrics, "~> 1.0.0", [hex: :metrics, repo: "hexpm", optional: false]}, {:mimerl, "~> 1.1", [hex: :mimerl, repo: "hexpm", optional: false]}, {:parse_trans, "3.3.1", [hex: :parse_trans, repo: "hexpm", optional: false]}, {:ssl_verify_fun, "~> 1.1.0", [hex: :ssl_verify_fun, repo: "hexpm", optional: false]}, {:unicode_util_compat, "~> 0.7.0", [hex: :unicode_util_compat, repo: "hexpm", optional: false]}], "hexpm", "a4ecdaff44297e9b5894ae499e9a070ea1888c84afdd1fd9b7b2bc384950128e"}, "idna": {:hex, :idna, "6.1.1", "8a63070e9f7d0c62eb9d9fcb360a7de382448200fbbd1b106cc96d3d8099df8d", [:rebar3], [{:unicode_util_compat, "~>0.7.0", [hex: :unicode_util_compat, repo: "hexpm", optional: false]}], "hexpm", "92376eb7894412ed19ac475e4a86f7b413c1b9fbb5bd16dccd57934157944cea"}, - "jason": {:hex, :jason, "1.2.2", "ba43e3f2709fd1aa1dce90aaabfd039d000469c05c56f0b8e31978e03fa39052", [:mix], [{:decimal, "~> 1.0 or ~> 2.0", [hex: :decimal, repo: "hexpm", optional: true]}], "hexpm", "18a228f5f0058ee183f29f9eae0805c6e59d61c3b006760668d8d18ff0d12179"}, + "jason": {:hex, :jason, "1.4.0", "e855647bc964a44e2f67df589ccf49105ae039d4179db7f6271dfd3843dc27e6", [:mix], [{:decimal, "~> 1.0 or ~> 2.0", [hex: :decimal, repo: "hexpm", optional: true]}], "hexpm", "79a3791085b2a0f743ca04cec0f7be26443738779d09302e01318f97bdb82121"}, "makeup": {:hex, :makeup, "1.1.0", "6b67c8bc2882a6b6a445859952a602afc1a41c2e08379ca057c0f525366fc3ca", [:mix], [{:nimble_parsec, "~> 1.2.2 or ~> 1.3", [hex: :nimble_parsec, repo: "hexpm", optional: false]}], "hexpm", "0a45ed501f4a8897f580eabf99a2e5234ea3e75a4373c8a52824f6e873be57a6"}, "makeup_elixir": {:hex, :makeup_elixir, "0.16.0", "f8c570a0d33f8039513fbccaf7108c5d750f47d8defd44088371191b76492b0b", [:mix], [{:makeup, "~> 1.0", [hex: :makeup, repo: "hexpm", optional: false]}, {:nimble_parsec, "~> 1.2.3", [hex: :nimble_parsec, repo: "hexpm", optional: false]}], "hexpm", "28b2cbdc13960a46ae9a8858c4bebdec3c9a6d7b4b9e7f4ed1502f8159f338e7"}, "makeup_erlang": {:hex, :makeup_erlang, "0.1.1", "3fcb7f09eb9d98dc4d208f49cc955a34218fc41ff6b84df7c75b3e6e533cc65f", [:mix], [{:makeup, "~> 1.0", [hex: :makeup, repo: "hexpm", optional: false]}], "hexpm", "174d0809e98a4ef0b3309256cbf97101c6ec01c4ab0b23e926a9e17df2077cbb"}, diff --git a/priv/plts/.gitignore b/priv/plts/.gitignore new file mode 100644 index 0000000..72e8ffc --- /dev/null +++ b/priv/plts/.gitignore @@ -0,0 +1 @@ +* diff --git a/test/spear/connection_test.exs b/test/spear/connection_test.exs index 018cd88..d02fe63 100644 --- a/test/spear/connection_test.exs +++ b/test/spear/connection_test.exs @@ -3,7 +3,11 @@ defmodule Spear.ConnectionTest do import ExUnit.CaptureLog - @good_config Application.fetch_env!(:spear, :config) + @good_config Application.compile_env!(:spear, :config) + + defmodule MfaTest do + def send_me(pid), do: send(pid, :mfa_invoked) + end describe "given a connection_string leading nowhere" do setup do @@ -77,14 +81,8 @@ defmodule Spear.ConnectionTest do end test "a connection started with a :on_connect MFA invokes it at each connection" do - defmodule MfaTest do - def send_me(pid), do: send(pid, :mfa_invoked) - end - my_pid = self() - config = [{:on_connect, {MfaTest, :send_me, [my_pid]}} | @good_config] - conn = start_supervised!({Spear.Connection, config}) assert_receive(:mfa_invoked) @@ -94,14 +92,8 @@ defmodule Spear.ConnectionTest do end test "a connection started with a :on_disconnect MFA invokes it at each disconnection" do - defmodule MfaTest do - def send_me(pid), do: send(pid, :mfa_invoked) - end - my_pid = self() - config = [{:on_disconnect, {MfaTest, :send_me, [my_pid]}} | @good_config] - conn = start_supervised!({Spear.Connection, config}) assert Connection.call(conn, :close) == {:ok, :closed}