graphql-engine/server/src-test/Hasura/Tracing/TraceIdSpec.hs
awjchen dcca0c6275 server: support 128-bit trace ids
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/5905
GitOrigin-RevId: 48a981a432b2e979bc7b42b32f9c7f53ab9e2598
2022-09-20 02:50:06 +00:00

30 lines
900 B
Haskell

module Hasura.Tracing.TraceIdSpec (spec) where
import Hasura.Prelude
import Hasura.Tracing.TraceId
( randomSpanId,
randomTraceId,
spanIdFromBytes,
spanIdToBytes,
traceIdFromBytes,
traceIdToBytes,
)
import Test.Hspec
spec :: Spec
spec = do
describe "TraceId" $ do
it "roundtrips to and from ByteString" $ do
let randomRoundTrip :: IO Bool
randomRoundTrip =
randomTraceId <&> \traceId ->
traceIdFromBytes (traceIdToBytes traceId) == Just traceId
fmap and (replicateM 100 randomRoundTrip) `shouldReturn` True
describe "SpanId" $ do
it "roundtrips to and from ByteString" $ do
let randomRoundTrip :: IO Bool
randomRoundTrip =
randomSpanId <&> \spanId ->
spanIdFromBytes (spanIdToBytes spanId) == Just spanId
fmap and (replicateM 100 randomRoundTrip) `shouldReturn` True