attoparsec-framer-0.1.0.3: Use Attoparsec to parse framed protocol byte streams
Copyright(c) 2022 Tim Emiola
LicenseBSD3
MaintainerTim Emiola <adetokunbo@emio.la>
Safe HaskellSafe-Inferred
LanguageHaskell2010

Data.Attoparsec.Framer.Testing

Description

This module provides combinators that simplify unit tests of code that use Framers.

Synopsis

testing combinators

parsesFromFramerOk :: Eq a => (a -> ByteString) -> Parser a -> Word32 -> [a] -> IO Bool Source #

Creates a Framer and uses 'runFramer to confirm that the expect frames are received '

chunksOfN :: Int -> ByteString -> [ByteString] Source #

Split a ByteString into chunks of given size

linkedSrcAndSink :: [ByteString] -> IO (ByteSource IO, ByteString -> IO ()) Source #

A ByteSource linked to a byte sink.

Provides a ByteSource and byte sink that emulate a responding endpoint.

The responses are consumed each time the byte sink is invoked.

Whenever the sink is invoked, the head of the provided responses is removed and starts to be returned in chunks by the ByteSource,

linkedSrcAndSink' :: [ByteString] -> IO (ByteSource IO, ByteString -> IO ()) Source #

Like linkedSrcAndSink, but prints the src and sink to output as debug