Cristiano Piemontese 0cc8c760d0
Add telepoison (#148)
* add telepoison

* rename

* rename file too, duh

* rename test file

* port updates

* add standard workflow
2023-06-04 08:23:03 -06:00

51 lines
1.3 KiB
Elixir

defmodule OpentelemetryHTTPoison.URITest do
@moduledoc """
Tests for `OpentelemetryHTTPoison.URI`
"""
alias HTTPoison.Request
use ExUnit.Case
alias OpentelemetryHTTPoison.URI, as: UtilsURI
@base_uri "https://www.test.com"
describe "infer_route_from_request/1" do
test "Request URL consisiting of whitespace is inferred as a route of '/'" do
request = %Request{url: ""}
result = UtilsURI.infer_route_from_request(request)
assert result == "/"
end
test "Request URL '#{@base_uri}/user/edit/24' is inferred as a route of '/user/:subpath'" do
url = "#{@base_uri}/user/edit/24"
request = %Request{url: url}
result = UtilsURI.infer_route_from_request(request)
assert result == "/user/:subpath"
end
test "Request URL '#{@base_uri}/user/24' is inferred as a route of '/user/:subpath'" do
url = "#{@base_uri}/user/24"
request = %Request{url: url}
result = UtilsURI.infer_route_from_request(request)
assert result == "/user/:subpath"
end
test "Request URL #{@base_uri}/'user' is inferred as route of '/user'" do
url = "#{@base_uri}/user"
request = %Request{url: url}
result = UtilsURI.infer_route_from_request(request)
assert result == "/user"
end
end
end