graphql-engine/server/src-test/Hasura/Tracing/TraceIdSpec.hs

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

30 lines
900 B
Haskell
Raw Normal View History

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