 logger = new Log 'info'
 
 Symphony = require '../src/symphony'
+Q = require 'q'
 
 throw new Error('BOT_USER_CERT undefined') unless process.env.BOT_USER_CERT
 throw new Error('BOT_USER_KEY undefined') unless process.env.BOT_USER_KEY

    logger.info "Received '#{msg.message}'" for msg in response when msg.v2messageType = 'V2Message'
    process.exit(0)
  .fail (err) ->
    logger.error "Failed to receive a message: #{err}"
    process.exit(2)


logger.info 'Connections initiated, starting tests...'

# print bot & user account diagnostics, send message from user -> bot and verify receipt
userConnection.whoAmI()
  .then (response) ->
    userConnection.getUser({userId: response.userId})
  .then (response) ->
    logger.info "User name is #{response.displayName} [#{response.emailAddress}]"
    botConnection.whoAmI()
  .then (response) ->
    botConnection.getUser({userId: response.userId})
  .then (response) ->
    logger.info "Bot name is #{response.displayName} [#{response.emailAddress}]"
    # get conversation between user & bot
    userConnection.createIM(response.id)
  .then (response) ->
    # send ping from user to bot
    userConnection.sendMessage(response.id, "ping", "TEXT")
  .then (response) ->
    botConnection.createDatafeed()
  .then (response) ->
    logger.info "Created datafeed: #{response.id}"
    botConnection.readDatafeed(response.id)
