Open
Description
I'd like to propose some tests that we can add to this project so that updates can be made with higher confidence that they don't change the existing behaviour.
My wish-list would be to have high coverage of the public APIs exported by this package. I'll create a PR that updates the npm test script to run mocha against some Connection
and Session
tests as a base to build on. (I chose mocha to match what rhea is using.)
Here's a list of tests I think should be added based on the API that's exposed today. This list doesn't cover 100% of the API (some error validation would be nice) but should at least cover the happy path.
Connection
- Connection.open
Ensure the connection is in an 'opened' state after Connection.open() yields. - Connection.close
Ensure the connection is no longer in an 'opened' state after Connection.close() yields. - Connection.isOpen()
EnsureisOpen()
istrue
afterConnection.open()
yields. - Connection.isOpen()
EnsureisOpen()
isfalse
afterConnection.close()
yields. - Connection.isRemoteOpen()
EnsureisRemoteOpen()
istrue
afterConnection.open()
yields. - Connection.isRemoteOpen()
EnsureisRemoteOpen()
isfalse
afterConnection.close()
yields. - Connection.on('connectionOpen')
Ensure the connection fires theconnectionOpen
event whenConnection.open()
is called. - Connection.on('connectionClose')
Ensure the connection fires theconnectionClose
event whenConnection.close()
is called. - Connection.on('connectionError')
Ensure the connection fires theconnectionError
event when service closes the connection with an error. - Connection.createSession()
Ensure the session is created and in anopen
state. - Connection.createSender()
CallcreateSender()
without a session and ensure the sender is created and in anopen
state. - Connection.createSender()
CallcreateSender()
with a session and ensure the sender is created and in anopen
state. - Connection.createAwaitableSender()
Ensure the sender is created and in anopen
state. - Connection.createReceiver()
Ensure the receiver is created and in anopen
state. - Connection.createRequestResponseLink()
Ensure the RequestResponseLink is created and in anopen
state. - Connection.removeSession()
Create a session viaConnection.createSession()
, remove session viaConnection.removeSession()
and ensuresession.remove()
is called.
Session
- Session.begin()
Ensure the session fires thesessionOpen
event. - Session.close()
Ensure the session is fully closed afterSession.close()
yields. - Session.isOpen()
EnsureisOpen()
istrue
afterconnection.createSession
resolves. - Session.isOpen()
EnsureisOpen()
istrue
after thesessionOpen
event is fired. - Session.isClosed()
EnsureisClosed()
istrue
afterSession.close()
yields. - Session.isItselfClosed()
EnsureisItselfClosed()
istrue
afterSession.close()
yields. - Session.remove()
Ensure the session does not have any event listeners registered. - Session.on('sessionOpen')
Ensure the session fires thesessionOpen
event aftersession.begin()
is called. - Session.on('sessionClose')
Ensure the session fires thesessionClose
event aftersession.close()
is called. - Session.connection
Ensuresession.connection
matches theConnection
used to instantiate theSession
. - Session.createSender()
Ensure the sender is created and in anopen
state. - Session.createAwaitableSender()
Ensure the sender is created and in anopen
state. - Session.createReceiver()
Ensure the receiver is created and in anopen
state.
RequestResponseLink
- Connection.createRequestResponseLink()
Call method withoutprovidedSession
and ensure the return value includes the following fields,each in theopen
state:session
sender
receiver
- Connection.createRequestResponseLink()
Call method withprovidedSession
and ensure thesession
in the return value matches thesession
provided.
Sender
- Sender.isOpen()
EnsureisOpen()
returnstrue
afterconnection.createSender()
resolves. - Sender.isRemoteOpen()
EnsureisRemoteOpen()
returnstrue
afterconnection.createSender()
resolves. - Sender.isClosed()
EnsureisClosed
returnstrue
aftersender.close()
resolves. - Sender.isItselfClosed()
EnsureisItselfClosed
returnstrue
aftersender.close()
resolves. - Sender.isSender()
EnsureisSender()
returns true. - Sender.isReceiver()
EnsureisReceiver()
returns false. - Sender.remove()
Ensure thesender
and thesession
do not have any event listeners registered. - Sender.close()
Don't setcloseSession
, and ensuresender
andsession
are closed. - Sender.close()
SetcloseSession
totrue
, and ensuresender
andsession
are closed. - Sender.close()
SetcloseSession
tofalse
, and ensuresender
is closed andsession
is open. - Sender.name
Returns the sender's name. - Sender.session
Ensure thesender.session
matches theSession
used to instantiate theSender
. - Sender.connection
Ensure thesender.connection
matches theConnection
used to instantiate theSender
. - Sender.setDrained()
Ensureset_drained()
is called on the rhea link. - Sender.sendable()
Ensuresendable()
is called on the rhea link. - Sender.send()
Ensuresend()
is called on the rhea link with message, tag and format.
AwaitableSender
- Sender.send()
Ensuresend
is called on the rhea link with message, tag and format.
Receiver
- Receiver.isOpen()
EnsureisOpen()
returnstrue
afterconnection.createReceiver()
resolves. - Receiver.isRemoteOpen()
EnsureisRemoteOpen()
returnstrue
afterconnection.createReceiver()
resolves. - Receiver.isClosed()
EnsureisClosed
returnstrue
afterreceiver.close()
resolves. - Receiver.isItselfClosed()
EnsureisItselfClosed
returnstrue
afterreceiver.close()
resolves. - Receiver.isSender()
EnsureisSender()
returnsfalse
. - Receiver.isReceiver()
EnsureisReceiver()
returnstrue
. - Receiver.remove()
Ensure thereceiver
and thesession
do not have any event listeners registered. - Receiver.close()
Don't setcloseSession
, and ensurereceiver
andsession
are closed. - Receiver.close()
SetcloseSession
totrue
, and ensurereceiver
andsession
are closed. - Receiver.close()
SetcloseSession
tofalse
, and ensurereceiver
is closed andsession
is open. - Receiver.name
Returns the receiver's name. - Receiver.session
Ensure thereceiver.session
matches theSession
used to instantiate theReceiver
. - Receiver.connection
Ensure thereceiver.connection
matches theConnection
used to instantiate theReceiver
.
Metadata
Metadata
Assignees
Labels
No labels