Skip to content

[Ops] Add tests to project #58

Open
@chradek

Description

@chradek

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()
    Ensure isOpen() is true after Connection.open() yields.
  • Connection.isOpen()
    Ensure isOpen() is false after Connection.close() yields.
  • Connection.isRemoteOpen()
    Ensure isRemoteOpen() is true after Connection.open() yields.
  • Connection.isRemoteOpen()
    Ensure isRemoteOpen() is false after Connection.close() yields.
  • Connection.on('connectionOpen')
    Ensure the connection fires the connectionOpen event when Connection.open() is called.
  • Connection.on('connectionClose')
    Ensure the connection fires the connectionClose event when Connection.close() is called.
  • Connection.on('connectionError')
    Ensure the connection fires the connectionError event when service closes the connection with an error.
  • Connection.createSession()
    Ensure the session is created and in an open state.
  • Connection.createSender()
    Call createSender() without a session and ensure the sender is created and in an open state.
  • Connection.createSender()
    Call createSender() with a session and ensure the sender is created and in an open state.
  • Connection.createAwaitableSender()
    Ensure the sender is created and in an open state.
  • Connection.createReceiver()
    Ensure the receiver is created and in an open state.
  • Connection.createRequestResponseLink()
    Ensure the RequestResponseLink is created and in an open state.
  • Connection.removeSession()
    Create a session via Connection.createSession(), remove session via Connection.removeSession() and ensure session.remove() is called.

Session

  • Session.begin()
    Ensure the session fires the sessionOpen event.
  • Session.close()
    Ensure the session is fully closed after Session.close() yields.
  • Session.isOpen()
    Ensure isOpen() is true after connection.createSession resolves.
  • Session.isOpen()
    Ensure isOpen() is true after the sessionOpen event is fired.
  • Session.isClosed()
    Ensure isClosed() is true after Session.close() yields.
  • Session.isItselfClosed()
    Ensure isItselfClosed() is true after Session.close() yields.
  • Session.remove()
    Ensure the session does not have any event listeners registered.
  • Session.on('sessionOpen')
    Ensure the session fires the sessionOpen event after session.begin() is called.
  • Session.on('sessionClose')
    Ensure the session fires the sessionClose event after session.close() is called.
  • Session.connection
    Ensure session.connection matches the Connection used to instantiate the Session.
  • Session.createSender()
    Ensure the sender is created and in an open state.
  • Session.createAwaitableSender()
    Ensure the sender is created and in an open state.
  • Session.createReceiver()
    Ensure the receiver is created and in an open state.

RequestResponseLink

  • Connection.createRequestResponseLink()
    Call method without providedSession and ensure the return value includes the following fields,each in the open state:
    • session
    • sender
    • receiver
  • Connection.createRequestResponseLink()
    Call method with providedSession and ensure the session in the return value matches the session provided.

Sender

  • Sender.isOpen()
    Ensure isOpen() returns true after connection.createSender() resolves.
  • Sender.isRemoteOpen()
    Ensure isRemoteOpen() returns true after connection.createSender() resolves.
  • Sender.isClosed()
    Ensure isClosed returns true after sender.close() resolves.
  • Sender.isItselfClosed()
    Ensure isItselfClosed returns true after sender.close() resolves.
  • Sender.isSender()
    Ensure isSender() returns true.
  • Sender.isReceiver()
    Ensure isReceiver() returns false.
  • Sender.remove()
    Ensure the sender and the session do not have any event listeners registered.
  • Sender.close()
    Don't set closeSession, and ensure sender and session are closed.
  • Sender.close()
    Set closeSession to true, and ensure sender and session are closed.
  • Sender.close()
    Set closeSession to false, and ensure sender is closed and session is open.
  • Sender.name
    Returns the sender's name.
  • Sender.session
    Ensure the sender.session matches the Session used to instantiate the Sender.
  • Sender.connection
    Ensure the sender.connection matches the Connection used to instantiate the Sender.
  • Sender.setDrained()
    Ensure set_drained() is called on the rhea link.
  • Sender.sendable()
    Ensure sendable() is called on the rhea link.
  • Sender.send()
    Ensure send() is called on the rhea link with message, tag and format.

AwaitableSender

  • Sender.send()
    Ensure send is called on the rhea link with message, tag and format.

Receiver

  • Receiver.isOpen()
    Ensure isOpen() returns true after connection.createReceiver() resolves.
  • Receiver.isRemoteOpen()
    Ensure isRemoteOpen() returns true after connection.createReceiver() resolves.
  • Receiver.isClosed()
    Ensure isClosed returns true after receiver.close() resolves.
  • Receiver.isItselfClosed()
    Ensure isItselfClosed returns true after receiver.close() resolves.
  • Receiver.isSender()
    Ensure isSender() returns false.
  • Receiver.isReceiver()
    Ensure isReceiver() returns true.
  • Receiver.remove()
    Ensure the receiver and the session do not have any event listeners registered.
  • Receiver.close()
    Don't set closeSession, and ensure receiver and session are closed.
  • Receiver.close()
    Set closeSession to true, and ensure receiver and session are closed.
  • Receiver.close()
    Set closeSession to false, and ensure receiver is closed and session is open.
  • Receiver.name
    Returns the receiver's name.
  • Receiver.session
    Ensure the receiver.session matches the Session used to instantiate the Receiver.
  • Receiver.connection
    Ensure the receiver.connection matches the Connection used to instantiate the Receiver.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions