From 04686eed1acf21be697197f33ce60ab56e5d3ba9 Mon Sep 17 00:00:00 2001 From: Michael Crumm Date: Wed, 5 Oct 2022 14:45:56 -0700 Subject: [PATCH] Normalize test endpoint port --- lib/absinthe_client.ex | 10 +++++----- lib/absinthe_client/web_socket.ex | 26 +++++++++++++------------- test/test_helper.exs | 2 +- 3 files changed, 19 insertions(+), 19 deletions(-) diff --git a/lib/absinthe_client.ex b/lib/absinthe_client.ex index 1a0355e..2860820 100644 --- a/lib/absinthe_client.ex +++ b/lib/absinthe_client.ex @@ -147,7 +147,7 @@ defmodule AbsintheClient do Performing a `subscription` operation: - iex> req = Req.new(base_url: "http://localhost:8001") |> AbsintheClient.attach() + iex> req = Req.new(base_url: "http://localhost:4002") |> AbsintheClient.attach() iex> ws = req |> AbsintheClient.WebSocket.connect!() iex> Req.request!(req, ...> web_socket: ws, @@ -167,7 +167,7 @@ defmodule AbsintheClient do Performing an asynchronous `subscription` operation and awaiting the reply: - iex> req = Req.new(base_url: "http://localhost:8001") |> AbsintheClient.attach() + iex> req = Req.new(base_url: "http://localhost:4002") |> AbsintheClient.attach() iex> ws = req |> AbsintheClient.WebSocket.connect!() iex> res = Req.request!(req, ...> web_socket: ws, @@ -189,7 +189,7 @@ defmodule AbsintheClient do Authorization via the request `:auth` option: - iex> req = Req.new(base_url: "http://localhost:8001/", auth: {:bearer, "valid-token"}) |> AbsintheClient.attach() + iex> req = Req.new(base_url: "http://localhost:4002/", auth: {:bearer, "valid-token"}) |> AbsintheClient.attach() iex> ws = req |> AbsintheClient.WebSocket.connect!(url: "/auth-socket/websocket") iex> res = Req.request!(req, ...> web_socket: ws, @@ -212,7 +212,7 @@ defmodule AbsintheClient do Custom authorization via `:connect_params` map literal: iex> req = - ...> Req.new(base_url: "http://localhost:8001/") + ...> Req.new(base_url: "http://localhost:4002/") ...> |> AbsintheClient.attach(connect_params: %{"token" => "valid-token"}) iex> ws = req |> AbsintheClient.WebSocket.connect!(url: "/auth-socket/websocket") iex> res = Req.request!(req, @@ -236,7 +236,7 @@ defmodule AbsintheClient do Failed authorization replies will timeout: iex> req = - ...> Req.new(base_url: "http://localhost:8001/", auth: {:bearer, "invalid-token"}) + ...> Req.new(base_url: "http://localhost:4002/", auth: {:bearer, "invalid-token"}) ...> |> AbsintheClient.attach(retry: :never) iex> ws = req |> AbsintheClient.WebSocket.connect!(url: "/auth-socket/websocket") iex> res = Req.request!(req, diff --git a/lib/absinthe_client/web_socket.ex b/lib/absinthe_client/web_socket.ex index eb74362..b81e8b5 100644 --- a/lib/absinthe_client/web_socket.ex +++ b/lib/absinthe_client/web_socket.ex @@ -19,14 +19,14 @@ defmodule AbsintheClient.WebSocket do Performing a `query` operation over a WebSocket: - iex> req = Req.new(base_url: "http://localhost:8001") |> AbsintheClient.attach() + iex> req = Req.new(base_url: "http://localhost:4002") |> AbsintheClient.attach() iex> ws = req |> AbsintheClient.WebSocket.connect!() iex> Req.request!(req, web_socket: ws, graphql: ~S|{ __type(name: "Repo") { name } }|).body["data"] %{"__type" => %{"name" => "Repo"}} Performing an async `query` operation and awaiting the reply: - iex> req = Req.new(base_url: "http://localhost:8001") |> AbsintheClient.attach() + iex> req = Req.new(base_url: "http://localhost:4002") |> AbsintheClient.attach() iex> ws = req |> AbsintheClient.WebSocket.connect!() iex> reply = ...> req @@ -96,14 +96,14 @@ defmodule AbsintheClient.WebSocket do From a request: - iex> req = Req.new(base_url: "http://localhost:8001") |> AbsintheClient.attach() + iex> req = Req.new(base_url: "http://localhost:4002") |> AbsintheClient.attach() iex> {:ok, ws} = req |> AbsintheClient.WebSocket.connect() iex> ws |> GenServer.whereis() |> Process.alive?() true From keyword options: - iex> {:ok, ws} = AbsintheClient.WebSocket.connect(url: "ws://localhost:8001/socket/websocket") + iex> {:ok, ws} = AbsintheClient.WebSocket.connect(url: "ws://localhost:4002/socket/websocket") iex> ws |> GenServer.whereis() |> Process.alive?() true """ @@ -128,14 +128,14 @@ defmodule AbsintheClient.WebSocket do With the default URL path: - iex> req = Req.new(base_url: "http://localhost:8001") |> AbsintheClient.attach() + iex> req = Req.new(base_url: "http://localhost:4002") |> AbsintheClient.attach() iex> {:ok, ws} = req |> AbsintheClient.WebSocket.connect() iex> ws |> GenServer.whereis() |> Process.alive?() true With a custom URL path: - iex> req = Req.new(base_url: "http://localhost:8001") |> AbsintheClient.attach() + iex> req = Req.new(base_url: "http://localhost:4002") |> AbsintheClient.attach() iex> {:ok, ws} = req |> AbsintheClient.WebSocket.connect(url: "/socket/websocket") iex> ws |> GenServer.whereis() |> Process.alive?() true @@ -226,13 +226,13 @@ defmodule AbsintheClient.WebSocket do From a request: - iex> ws = Req.new(base_url: "http://localhost:8001") |> AbsintheClient.WebSocket.connect!() + iex> ws = Req.new(base_url: "http://localhost:4002") |> AbsintheClient.WebSocket.connect!() iex> ws |> GenServer.whereis() |> Process.alive?() true From keyword options: - iex> ws = AbsintheClient.WebSocket.connect!(url: "ws://localhost:8001/socket/websocket") + iex> ws = AbsintheClient.WebSocket.connect!(url: "ws://localhost:4002/socket/websocket") iex> ws |> GenServer.whereis() |> Process.alive?() true """ @@ -250,7 +250,7 @@ defmodule AbsintheClient.WebSocket do ## Examples iex> ws = - ...> Req.new(base_url: "http://localhost:8001") + ...> Req.new(base_url: "http://localhost:4002") ...> |> AbsintheClient.WebSocket.connect!(url: "/socket/websocket") iex> ws |> GenServer.whereis() |> Process.alive?() true @@ -278,7 +278,7 @@ defmodule AbsintheClient.WebSocket do ## Examples - iex> req = Req.new(base_url: "http://localhost:8001") |> AbsintheClient.attach() + iex> req = Req.new(base_url: "http://localhost:4002") |> AbsintheClient.attach() iex> ws = req |> AbsintheClient.WebSocket.connect!() iex> Req.request!(req, web_socket: ws, graphql: ~S|{ __type(name: "Repo") { name } }|).body["data"] %{"__type" => %{"name" => "Repo"}} @@ -313,7 +313,7 @@ defmodule AbsintheClient.WebSocket do ## Examples - iex> {:ok, req} = AbsintheClient.WebSocket.connect(url: "ws://localhost:8001/socket/websocket") + iex> {:ok, req} = AbsintheClient.WebSocket.connect(url: "ws://localhost:4002/socket/websocket") iex> ref = AbsintheClient.WebSocket.push(req, ~S|{ __type(name: "Repo") { name } }|) iex> AbsintheClient.WebSocket.await_reply!(ref).payload["data"] %{"__type" => %{"name" => "Repo"}} @@ -344,7 +344,7 @@ defmodule AbsintheClient.WebSocket do ## Examples - iex> req = Req.new(base_url: "http://localhost:8001") |> AbsintheClient.attach(async: true) + iex> req = Req.new(base_url: "http://localhost:4002") |> AbsintheClient.attach(async: true) iex> {:ok, ws} = AbsintheClient.WebSocket.connect(req) iex> {:ok, res} = Req.request(req, web_socket: ws, graphql: ~S|{ __type(name: "Repo") { name } }|) iex> {:ok, reply} = AbsintheClient.WebSocket.await_reply(res) @@ -381,7 +381,7 @@ defmodule AbsintheClient.WebSocket do ## Examples - iex> req = Req.new(base_url: "http://localhost:8001") |> AbsintheClient.attach(async: true) + iex> req = Req.new(base_url: "http://localhost:4002") |> AbsintheClient.attach(async: true) iex> ws = req |> AbsintheClient.WebSocket.connect!() iex> res = Req.post!(req, web_socket: ws, graphql: ~S|{ __type(name: "Repo") { name } }|) iex> AbsintheClient.WebSocket.await_reply!(res).payload["data"] diff --git a/test/test_helper.exs b/test/test_helper.exs index 90461bf..8132451 100644 --- a/test/test_helper.exs +++ b/test/test_helper.exs @@ -1,5 +1,5 @@ Application.put_env(:absinthe_client, AbsintheClientTest.Endpoint, - http: [ip: {127, 0, 0, 1}, port: 8001], + http: [ip: {127, 0, 0, 1}, port: 4002], secret_key_base: "HOJE5xctETrtYS5RfAG+Ivz35iKH7JXyVz7MN6ExwmjIDVMVXoMbpHrp8ZEt++cK", check_origin: false, pubsub_server: AbsintheClientTest.PubSub,