Skip to content

Commit

Permalink
Allow for a string to be passed to override request name on per-reque…
Browse files Browse the repository at this point in the history
…st basis
  • Loading branch information
zkayser committed Oct 21, 2024
1 parent b1a972e commit cac9517
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions test/car_req_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -803,6 +803,24 @@ defmodule CarReqTest do
assert override_fun.(url) == ResourceNameOverrideRuntimeClient.request_override(url)
end

test "allows a hard-coded string to replace resource_name on a per-request basis rather than a function" do
defmodule StringResourceNameReplacementClient do
use CarReq
end

StringResourceNameReplacementClient.request(
method: :get,
url: "employees/1234/details",
adapter: &Adapter.success/1,
resource_name_override: "get employees_details_endpoint"
)

assert_receive {:event, [:http_car_req, :request, :start], _,
%{resource_name_override: override}}

assert override == "get employees_details_endpoint"
end

test "determines service name for external namespaced clients" do
defmodule Test.Foo.Bar.External.Service.ServiceNameClient do
use CarReq
Expand Down

0 comments on commit cac9517

Please sign in to comment.