Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Q
quasar-network
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Jens Nolte
quasar-network
Commits
69b9f5ba
Commit
69b9f5ba
authored
3 years ago
by
Jens Nolte
Browse files
Options
Downloads
Patches
Plain Diff
Add test cases
parent
d656e4cb
Loading
Loading
Loading
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
test/Network/Rpc/MultiplexerSpec.hs
+46
-0
46 additions, 0 deletions
test/Network/Rpc/MultiplexerSpec.hs
with
46 additions
and
0 deletions
test/Network/Rpc/MultiplexerSpec.hs
+
46
−
0
View file @
69b9f5ba
...
...
@@ -36,6 +36,52 @@ spec = describe "runMultiplexerProtocol" $ parallel $ do
tryReadMVar
recvMVar
`
shouldReturn
`
Nothing
it
"it can create sub-channels"
$
do
recvMVar
<-
newEmptyMVar
withEchoServer
$
\
channel
->
do
channelSetHandler
channel
$
((
\
_
->
putMVar
recvMVar
)
::
ReceivedMessageResources
->
BSL
.
ByteString
->
IO
()
)
SentMessageResources
{
createdChannels
=
[
_
]}
<-
channelSend_
channel
[
CreateChannelHeader
]
"create a channel"
takeMVar
recvMVar
`
shouldReturn
`
"create a channel"
SentMessageResources
{
createdChannels
=
[
_
,
_
,
_
]}
<-
channelSend_
channel
[
CreateChannelHeader
,
CreateChannelHeader
,
CreateChannelHeader
]
"create more channels"
takeMVar
recvMVar
`
shouldReturn
`
"create more channels"
tryReadMVar
recvMVar
`
shouldReturn
`
Nothing
it
"it can send messages on sub-channels"
$
do
recvMVar
<-
newEmptyMVar
c1RecvMVar
<-
newEmptyMVar
c2RecvMVar
<-
newEmptyMVar
c3RecvMVar
<-
newEmptyMVar
withEchoServer
$
\
channel
->
do
channelSetHandler
channel
$
((
\
_
->
putMVar
recvMVar
)
::
ReceivedMessageResources
->
BSL
.
ByteString
->
IO
()
)
channelSendSimple
channel
"foobar"
takeMVar
recvMVar
`
shouldReturn
`
"foobar"
SentMessageResources
{
createdChannels
=
[
c1
,
c2
]}
<-
channelSend_
channel
[
CreateChannelHeader
,
CreateChannelHeader
]
"create channels"
takeMVar
recvMVar
`
shouldReturn
`
"create channels"
channelSetHandler
c1
$
((
\
_
->
putMVar
c1RecvMVar
)
::
ReceivedMessageResources
->
BSL
.
ByteString
->
IO
()
)
channelSetHandler
c2
$
((
\
_
->
putMVar
c2RecvMVar
)
::
ReceivedMessageResources
->
BSL
.
ByteString
->
IO
()
)
channelSendSimple
c1
"test"
takeMVar
c1RecvMVar
`
shouldReturn
`
"test"
channelSendSimple
c2
"test2"
takeMVar
c2RecvMVar
`
shouldReturn
`
"test2"
channelSendSimple
c2
"test3"
takeMVar
c2RecvMVar
`
shouldReturn
`
"test3"
channelSendSimple
c1
"test4"
takeMVar
c1RecvMVar
`
shouldReturn
`
"test4"
SentMessageResources
{
createdChannels
=
[
c3
]}
<-
channelSend_
channel
[
CreateChannelHeader
]
"create another channel"
takeMVar
recvMVar
`
shouldReturn
`
"create another channel"
channelSetHandler
c3
$
((
\
_
->
putMVar
c3RecvMVar
)
::
ReceivedMessageResources
->
BSL
.
ByteString
->
IO
()
)
channelSendSimple
c3
"test5"
takeMVar
c3RecvMVar
`
shouldReturn
`
"test5"
channelSendSimple
c1
"test6"
takeMVar
c1RecvMVar
`
shouldReturn
`
"test6"
tryReadMVar
recvMVar
`
shouldReturn
`
Nothing
withEchoServer
::
(
Channel
->
IO
a
)
->
IO
a
withEchoServer
fn
=
bracket
setup
close
(
\
(
channel
,
_
)
->
fn
channel
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment