this repo has no description
at main 1.8 kB view raw
1defmodule PlugOpenTracingTest do 2 use ExUnit.Case, async: true 3 use Plug.Test 4 alias Plug.Conn.Status 5 6 test "missing trace header results in new span" do 7 connection = conn(:get, "/test-path") 8 response = TestApp.call(connection, []) 9 10 assert response.status == Status.code(:ok) 11 assert response.resp_body != "" 12 end 13 14 test "bad trace header results in new span" do 15 connection = conn(:get, "/test-path") |> put_req_header("uber-trace-id", "1234") 16 response = TestApp.call(connection, []) 17 18 assert response.status == Status.code(:ok) 19 assert response.resp_body != "" 20 end 21 22 test "valid trace header results in span with those ids" do 23 connection = conn(:get, "/test-path") |> put_req_header("uber-trace-id", "6a5c63925e01051b:150b1b1adcde6f4:6a5c63925e01051b:1") 24 response = TestApp.call(connection, []) 25 26 assert response.status == Status.code(:ok) 27 assert response.resp_body == "7664110146171241755" 28 end 29 30 test "invalid hex trace header results in usable span" do 31 connection = conn(:get, "/test-path") |> put_req_header("uber-trace-id", "6a5x63925t01051b:150b1p1adcdq6f4:6a5c63925e01051b:1") 32 response = TestApp.call(connection, []) 33 34 assert response.status == Status.code(:ok) 35 assert response.resp_body == "1701" 36 end 37 38 test "empty trace header results in new span" do 39 connection = conn(:get, "/test-path") |> put_req_header("uber-trace-id", "") 40 response = TestApp.call(connection, []) 41 42 assert response.status == Status.code(:ok) 43 assert response.resp_body != "" 44 end 45 46 test "just some colons results in new span" do 47 connection = conn(:get, "/test-path") |> put_req_header("uber-trace-id", "::::") 48 response = TestApp.call(connection, []) 49 50 assert response.status == Status.code(:ok) 51 assert response.resp_body != "" 52 end 53end